百日半狂乱

Shut the fuck up and write some code!!

Python

0.1 + 0.1 + 0.1 == 0.3 ?

パーフェクトPythonを写経中に0.1 + 0.1 + 0.1について書いてあったのでメモ. Pythonのfloat(浮動小数点数型)は、大抵の場合はCのdouble型を使って実装されており、近代的なコンピュータの場合53ビットの精度らしい. Python $ python Python 2.7.3 (defaul…