I feel that the posting that indicates you’re not “100% satisfied” still mixes up a couple of things. As Daniel pointed out, there are two types of approximate real numbers in Mathematica, machine reals and arbitrary-precision numbers, a.k.a. bignums. Each type has different display rules. In the factory defaults, machine reals are displayed in rounded format (rounded to six digits, with trailing zeros truncated). Arbitrary-precision numbers are displayed with as many digits as their precision indicates, and the display includes trailing zeros. In neither case does the displayed digits completely represent the internal value, except in cases where the representation and the value happen to coincide. Also, one might take issue with the assertion that machine precision is “16 decimal digits,” depending on the emphasis on decimal digits. The number 0.1 is not represented exactly in binary floating-point, but has to be rounded (see below). Thus even one decimal digit cannot be represented (exactly). The principal issue, as it seem to me, of the discrepancy between display and internal value is inherent to displaying in decimal and value stored in binary. The only real solutions are getting a decimal computer or printing out in a binary format such as hex. (Excel tries to get around these kind of issues through “cosmetic” rounding, which causes other problems; see Kahan 2006, sect. 2.)
As a user I’ve found the number representation in Mathematica notebooks convenient, once I learned how to understand the output. Hand-held calculators do rounding (at least they used to), so it didn’t seem that unusual to me. Six digits meant I could read a medium-long list of numbers. The bignums are apparent by their digits, unless their precision is between one and six.
The documentation for PrintPrecision
PrintPrecision
is an option for selections that specifies the maximum number of digits used for displaying a machine-precision number.
The “Details” section hints at another workaround:
- The setting for
PrintPrecisionis only used whenNumberMarks -> False.
One can set these options for the current session or once for all (which writes the setting into your init.m file); or one can use Style[1/3., PrintPrecision -> 12] (or NumberMarks -> True) to override the defaults for a single output.
SetOptions[$FrontEndSession, NumberMarks -> True] (* for current session only *)
SetOptions[$FrontEnd, NumberMarks -> True] (* for current & future sessions *)
SetOptions[$FrontEndSession, PrintPrecision -> 12]
But note that this won’t relieve one of the impression that computers make arithmetic mistakes. The following will make sense only if you are familiar with the binary64 floating-point standard of IEEE-754:
SetOptions[$FrontEndSession, NumberMarks -> True];
0.1 + 0.2
(* Out[]=0.30000000000000004` *)
0.3
(* Out[]= 0.3` *)
The discrepancy is due to the way binary floating-point numbers are supposed to work according to the IEEE standard.
There is a decimal IEEE-754 standard that avoids the problem with binary. There are decimal machines (IBM POWER6 and System Z) and decimal math libraries, such as Intel® Decimal Floating-Point Math Library . Unfortunately, commonly available machines are binary.