# Thread: Arithmetic expression that will display doubles to only one decimal place?

1. Member
Join Date
Aug 2014
Posts
10
Rep Power
0

## Arithmetic expression that will display doubles to only one decimal place?

I am looking to find a way to display the number of decimal places without using any type of formatting string.
Only to make it xxx.x instead of xxx.xxxxxx.
Last edited by Argyros; 09-29-2014 at 01:41 AM.

2. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,226
Rep Power
13

## Re: Arithmetic expression that will display doubles to only one decimal place?

So you want to format a number without describing how to format a number. You can't do it unless you write your own

Regards,
Jim

3. ## Re: Arithmetic expression that will display doubles to only one decimal place?

Originally Posted by Argyros
I am looking to find a way to display the number of decimal places without using any type of formatting string.
Only to make it xxx.x instead of xxx.xxxxxx.
With or without a computer?

db

4. ## Re: Arithmetic expression that will display doubles to only one decimal place?

Originally Posted by DarrylBurke
With or without a computer?

kindest regards,

Jos ;-)

5. ## Re: Arithmetic expression that will display doubles to only one decimal place?

Originally Posted by JosAH

kindest regards,

Jos ;-)
The nearest I have to wood is one made from spiky green cacti that only works when you sit on it. Will that do?

db --- prepares --- to --- (oh you know the rest) · · · · ·:·

6. ## Re: Arithmetic expression that will display doubles to only one decimal place?

Originally Posted by DarrylBurke
The nearest I have to wood is one made from spiky green cacti that only works when you sit on it. Will that do?
No, our society that propagates "how not to sit on hedgehogs" have recently included cacti in our field of interest.

kindest regards,

Jos (<--- never sits on hedgehogs nor cacti (nor jellyfish for that matter))

7. Member
Join Date
Aug 2014
Posts
10
Rep Power
0

## Re: Arithmetic expression that will display doubles to only one decimal place?

Here is how I was told to do it.

With a little math manipulation, the number of decimal places can be formatted.
Try to write an arithmetic expression that will display doubles to only one
decimal place. (Hint: Write a decimal number with four or five decimal places on
a piece of paper. What kind of arithmetic will move the decimal point around
within the number? Don’t forget about casting, too.)

8. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,226
Rep Power
13

## Re: Arithmetic expression that will display doubles to only one decimal place?

This sounds like an exercise for you to develop your own formatting method. There is not
much more I can say than what was given. It is something you sort of have to see by playing
around with. I would first suggest you try to just convert a number like 23.398 to 23.3.
Then when you get that done, you can try to properly round it up. Doing this on paper first
is the best bet.

Regards,
Jim

9. ## Re: Arithmetic expression that will display doubles to only one decimal place?

And then we encounter ncb-goldberg ...

db

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•