Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^6: [OT: JavaScript] JS remainder operation ('%') (print's float rounding)

by syphilis (Archbishop)
on Jan 18, 2024 at 13:59 UTC ( [id://11157080]=note: print w/replies, xml ) Need Help??


in reply to Re^5: [OT: JavaScript] JS remainder operation ('%') (print's float rounding)
in thread [OT: JavaScript] JS remainder operation ('%')

Can't find it, shouldn't it be mentioned in print ?

Sounds like the logical spot for it. (Maybe we're still trying to come up with a justification ;-)

I recall reading (somewhere) that 15 digits was chosen because that's the value of float.h's DBL_DIG - and DBL_DIG is described as "DBL_DIG specifies the number of digits of precision of a double".
So you can see that someone could easily get sucked into thinking that 15 digits was the smart thing to do.

If you go beyond 15 digits, then you hit the case that 2 different 16-digit numbers can have the same value:
>perl -le "print 'ok' if 9.999999999999999 == 9.999999999999998;" ok
That's 2 different 16 digit numbers with the same value. Therefore the "number of digits of precision of a double" must be less than 16.
But you won't get 2 different 15-digit numbers with the same value.

Cheers,
Rob
  • Comment on Re^6: [OT: JavaScript] JS remainder operation ('%') (print's float rounding)
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11157080]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2024-05-21 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found