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

Re^3: Comparing results of math operations

by syphilis (Chancellor)
on Apr 16, 2014 at 14:14 UTC ( #1082516=note: print w/replies, xml ) Need Help??

in reply to Re^2: Comparing results of math operations
in thread Comparing results of math operations

But does switching to decimal floats solve all problems?

No ... but then rational arithmetic (where you keep divisor and numerator separate) also fails to solve all problems, as it falls down when you start to deal with irrational numbers such as sqrt(2) or transcendentals such as pi.

I think what drew me to decimal arithmetic was that the values that appeared in the OP's post were all *exactly* representable in base 10, as were the results of the calculations he presented.
If there had been a "1 / 3" (or some other rational value that couldn't be exactly represented in base 10) in that post then I would more likely have been drawn to modules such as Math::BigRat or Math::GMPq.

  • Comment on Re^3: Comparing results of math operations

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1082516]
[LanX]: what?
[LanX]: $; exists, so does the glob
[GotToBTru]: $; is "useful for emulating multi-dimensional arrays in Perl4"
[LanX]: i.e. &; is parsable

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2017-01-18 21:02 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (164 votes). Check out past polls.