On Wed, 28 Dec 2016 21:07:53 -0800, zefram@fysh.org wrote: > sisyphus1@optusnet.com.au wrote: > > FWIW, on Windows (perl-5.25.7, MSWin32-x64-multi-thread) y1 and y2 > > are the > > same as above, but y3 differs: > ... > > y3 = > > 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000 > > That's fucked up. Looks like it's libc's fault: sprintf() using a > crap algorithm, converting to decimal with a fixed precision and then > expanding that to the output precision, rather than actually > converting > to the output precision. Arguably we should implement our own float > formatter to avoid this sort of problem. I have a ticket open on using the netlib dtoa: https://rt.perl.org/Ticket/Display.html?id=122482 But am severely tuit-shortaged. FWIW I tried adding $x2 = '0x1.fffffffffffffp+1023'; $y4 = sprintf("%f", eval $x2); $y5 = sprintf("%f", 0x1.fffffffffffffp+1023); $y6 = sprintf("%a", DBL_MAX); print "y4 = $y4\n"; print "y5 = $y5\n"; print "y6 = $y6\n"; and got y4 = 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 y5 = 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 y6 = 0x1.fffffffffffffp+1023 which seems to indicate that the parsing of hexfp literals and the %a are okay (yay me). > But anyway, that's unrelated to the input problem with which this > ticket > is concerned. Open a separate ticket if you want to pursue it. > > -zefram --- via perlbug: queue: perl5 status: open https://rt.perl.org/Ticket/Display.html?id=130423Thread Previous | Thread Next