Es-discuss - several decimal discussions
rubys at intertwingly.net
Sun Aug 24 20:40:16 PDT 2008
On Sun, Aug 24, 2008 at 11:15 PM, Mark S. Miller <erights at google.com> wrote:
> On Sun, Aug 24, 2008 at 8:09 PM, Sam Ruby <rubys at intertwingly.net> wrote:
>> All things considered, I would argue for false.
> I'm curious. If 1.0m == 1.00m were false, what about 1.0m < 1.00m and
> 1.0m > 1.00m?
1.0m == 1.00m should be true.
But to answer your question, IEEE 754 does define a "total" ordering.
One can even test is using the implementation I posted a few weeks
js> Decimal.compareTotal(1.0m, 1.00m)
js> Decimal.compareTotal(1.00m, 1.0m)
"This function compares two numbers using the IEEE 754 total ordering.
If the lhs is less than the rhs in the total order then the number
will be set to the value -1. If they are equal, then number is set to
0. If the lhs is greater than the rhs then the number will be set to
the value 1.
The total order differs from the numerical comparison in that: –NaN <
–sNaN < –Infinity < –finites < –0 < +0 < +finites < +Infinity < +sNaN
< +NaN. Also, 1.000 < 1.0 (etc.) and NaNs are ordered by payload."
- Sam Ruby
More information about the Es-discuss