When I enter <( log 1000 <=> 3 )>
it says false
Last edited by rakhi (2009-12-13 22:42:19)
Offline
While you may think of log 1000 as an integer (whole number) value like 1,2,3 etc. the computer is calculating it as a floating point number with a decimal place like 3.000. Floating point numbers are really hard to compare on computers since they can't always be represented exactly by the binary numbers that the computer uses.
Probably, at a level invisible to the values you see on the display, the binary representation of the floating point result of the log 1000 operation does not equal the binary representation of the value 3 you entered.
To make a long story short...comparing for exact matches of floating point numbers is a very risky and problematic approach. It's better to use an error margin such as
[blocks]
<( <abs( (( log 1000 <-> 3 ))<<> 0.0001 )>
[/blocks]
Offline
Paddle2See wrote:
While you may think of log 1000 as an integer (whole number) value like 1,2,3 etc. the computer is calculating it as a floating point number with a decimal place like 3.000. Floating point numbers are really hard to compare on computers since they can't always be represented exactly by the binary numbers that the computer uses.
Probably, at a level invisible to the values you see on the display, the binary representation of the floating point result of the log 1000 operation does not equal the binary representation of the value 3 you entered.
To make a long story short...comparing for exact matches of floating point numbers is a very risky and problematic approach. It's better to use an error margin such as
[blocks]
<( <abs( (( log 1000 <-> 3 ))<<> 0.0001 )>
[/blocks]
Maybe we can try a variable(string)?
Offline