Message Boards Message Boards

0
|
5526 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Significant digits in integer numbers

Hi,

This seems to be a silly question, but I was not able to find an easy solution. I have an integer number which I must show as a currency. For example:

NumberForm[1738517, {1, 2}, DigitBlock -> 3]

How can I proceed to get this number to just one significant figure and still keeping the currency format (2,000,000.00)?

2 Replies
Posted 9 years ago

Hi

This will do it

NumberForm[Ceiling[1738517, 10^(IntegerLength[1738517] - 1)], {1, 2}, 
 DigitBlock -> 3]

The Ceiling function is the one to get it to n significant digits like

In[9]:= Ceiling[1738517, 1000000]

Out[9]= 2000000

You will need some means of identifying how many digits are in the number before hand, easy enough if the actual number is a variable.

Hope that helps.

POSTED BY: Paul Cleary

Dear Paul,

Thank you very much. This solved the problem. I just had to replace Ceiling by Round in order to correctly handle rounding.

Regards, Anderson

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract