in reply to Re^3: [OT: JavaScript] JS remainder operation ('%')
in thread [OT: JavaScript] JS remainder operation ('%')
When using print perl will "smoothen" the last digits of a floating point in order to "hide" potential rounding errors from previous operations.
This has been discussed here many times. Dunno if it's documented.
printf can be used to show the real content, of course only a binary format will be always fully correct.
$a = 1 - 1e-16; say $a; printf "%.16f",$a; __END__ 1 0.9999999999999999
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: [OT: JavaScript] JS remainder operation ('%') (print's float rounding)
by LanX (Saint) on Jan 18, 2024 at 13:02 UTC | |
by syphilis (Archbishop) on Jan 18, 2024 at 13:59 UTC |