IMO simulation is not necessary here --- double float is known to have 52 bits for the significand, so which tranlates to a bit less than 16 decimal digits, + 1 for rounding error (magnitude of rounding error is non-uniform when reading back from decimal), which is how you get 17, so clearly 15 is not enough.
On Wed, Nov 05 2014, Ivar Nesje <[email protected]> wrote: > The matlab docs clearly specifies format long as 15 digits > <http://www.mathworks.se/help/matlab/matlab_prog/display-format-for-numeric-values.html>. > > Julia usually prints 16 (or 17) digits for a call to rand(). > > This is a typical distribution of the number of digits from a > `rand(1_000_000)` call (eg, length(x)-2, to remove the 0. prefix) > > 10 1 > 11 12 > 12 67 > 13 624 > 14 6708 > 15 66337 > 16 610505 > 17 282185 > 18 30420 > 19 2944 > 20 197 > > This (probably) means that most often Matlab prints a number that can't be > parsed back to the same number. > > Code in gist <https://gist.github.com/ivarne/fe258ea95b9982827676> > > Ivar > > kl. 11:25:16 UTC+1 onsdag 5. november 2014 skrev Stefan Karpinski følgende: >> >> On Wed, Nov 5, 2014 at 2:48 AM, Jameson Nash <[email protected] >> <javascript:>> wrote: >> >>> fun fact: even with "format long", matlab doesn't always print enough >>> digits to reconstruct the number >>> >> >> Do you have an example? If true, this is rather horrifying. Is there >> simply no way to print a true value from Matlab then? >>
