On my CentOS 7 box with perl-5.16.3
That's certainly one instance where you
do benefit from formatting with "%.100f" instead of "%.100g".
Thank you for pointing this out.
Turns out that it's the same on my Ubuntu box with perl-5.18.0.
But with perl-5.32.0 on the same box, "%.100g" formatting works fine - so, there's a change in perl's behaviour between 5.18 and 5.32.
I would guess that "%.100g" formatting on your CentOS 7 box would also work fine on perl-5.32.
But I should point out that, even though "%.100g" formatting works ok on Ubuntu with perl-5.32.0, "%.*g" formatting is still buggy if you request a precision in the range 18..91 (inclusive).
$ perl -le 'printf "%.91f\n", 0.15;'
0.14999999999999999444888487687421729788184165954589843750000000000000
+00000000000000000000000
$ perl -le 'printf "%.91g\n", 0.15;'
0.14999999999999999
$ perl -le 'printf "%.92g\n", 0.15;'
0.1499999999999999944488848768742172978818416595458984375
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.