Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mathematica output formatting

How does Mathematica decide when to round numbers in its output? For example,

giving the input

250000.5

gives the output

2500001

While

25000.5

is indeed printed as

25000.5

N[] isn't helpful here either, I need to use NumberForm[] to get it to actually print 250000.5 as 250000.5

I'm a Mathematica newbie, and I'm sure its ridiculously easy to control this threshold for when it starts ignoring decimals in its output, but could somebody please point me in the right direction?

like image 918
JustDanyul Avatar asked Jul 17 '26 18:07

JustDanyul


2 Answers

another option for you to try, you can go to options and change the default PrintPrecision from 6 to say 16, and now you will see that it will print what you typed above

enter image description here

after I changed that to 16 (click on the field itself, and type 16 into the field to replace the 6, and hit return), then

enter image description here

like image 70
Nasser Avatar answered Jul 20 '26 08:07

Nasser


Nasser is correct that PrintPrecision is the right setting.

You have a number of options for its use. You can set it Globally or for the specific Notebook using the Options Inspector. You can also use it directly with Style:

Style[250000.5, PrintPrecision -> 10]
250000.5

You can set it temporarily for one session like this:

SetOptions[$FrontEndSession, PrintPrecision -> 10]

Finally you can set it using Style Sheets (select cell type Output).

like image 36
Mr.Wizard Avatar answered Jul 20 '26 08:07

Mr.Wizard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!