Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Okay! What!?!?!?

by sundialsvc4 (Abbot)
on Apr 23, 2014 at 02:09 UTC ( #1083255=note: print w/ replies, xml ) Need Help??


in reply to Okay! What!?!?!?

I don’t rightly know what the (stringwise ...) eq operator would do in this obviously-numeric case, and I would not want to find out, even if someone proclaimed that it “worked.”

Clearly, this is just a prototypical example of why you can never (in any programming language other than COBOL) test a fractional number for “exact equality.”   Even if the binary value rounds to exactly the same sequence of printed digits, and thus “to our human eyes” is ‘the same number,’ it is the binary values that are being compared by the computer, and these are almost certain to be “unequal.”


Comment on Re: Okay! What!?!?!?
Re^2: Okay! What!?!?!?
by moritz (Cardinal) on Apr 23, 2014 at 05:10 UTC
    Clearly, this is just a prototypical example of why you can never (in any programming language other than COBOL) test a fractional number for “exact equality.”

    Only if by "fractional number" you actually mean floating-point number. It works fine with actual fractional numbers:

    $ perl6 -e 'say 10 + 14.4 - 10 == 14.4' True

    (Perl 6 stores those as actual fractions, and does exact math with them; you only get floating points if the fractions overflow, or if you request them with the scientific notation 14.4e0).

      He said "programming language," not multi-decade performance art. COBOL has users.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2014-10-31 20:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (224 votes), past polls