printf "% 25.17g\n", -8.2727285363069939e-293;;
-8.2727285363069883e-293
Yeah, I get the same with mingw-built x64 5.22.0.
This is
the perl bug I alluded to in my first post that mis-assigns values by up to a few ULPs.
If you check the hex format (assigned by perl) of -8.2727285363069939e-293 you'll find:
C:\_32>perl -le "print scalar reverse unpack 'h*', pack 'd<', -8.27272
+85363069939e-293;"
834a6aec8f94134c
However, the correct hex format of -8.2727285363069939e-293 is 834a6aec8f941351.
834a6aec8f94134c does in fact correspond to -8.2727285363069883e-293 - so perl is doing the conversion from internal form to decimal string correctly. It's just the initial conversion from decimal string to internal form that was incorrect.
Sadly, no-one seems interested in fixing this - though I think that's because of the degree of difficulty rather than actual "disinterest".
If this level of inaccuracy bothers you (as it does me) then one solution is to assign using POSIX::strtod:
C:\_32>perl -MPOSIX -le "print scalar reverse unpack 'h*', pack 'd<',
+POSIX::strtod('-8.2727285363069939e-293');"
834a6aec8f941351
C:\_32>perl -MPOSIX -le "printf '% 25.17g', POSIX::strtod('-8.27272853
+63069939e-293');"
-8.2727285363069939e-293
This way you put your faith in the C compiler and that seems to be a safer bet.
(That's probably good enough, though I'd rather put my faith in the mpfr library.)
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.