3 ms·
Could you please grace us with a code sample for all of these? I'm not intimately familiar with Haskell, Lisp or Ruby. >>> from decimal import * >>> Decim
by godDLL 17y ago
Could you please grace us with a code sample for all of these? I'm not intimately familiar with Haskell, Lisp or Ruby.
>>> from decimal import *
>>> Decimal('0.3') == Decimal('0.1') + Decimal('0.2')
True
>>> Decimal('NaN') == Decimal('NaN')
False
>>>
- eslifka 17y agoYou only get that result in python by importing the decimal library. The standard behavior in python is (.1 + .2 == .3) == False However, your code example makes the excellent point that python has such a library available, whereas Javascript does not. At least, not as easily as an import.