2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

0.1+0.1+0.1は0.3じゃない

Last updated at Posted at 2024-12-11

Advent Calendar 2024の12日目です。

0.1+0.1+01は0.3じゃない

まんまです。pythonでちゃんとDecimal.from_floatで値を見たことがなかったのですが、

Decimal.from_float(0.1) = 0.1000000000000000055511151231257827021181583404541015625

のようです。なのでこれを

0.3(実際は0.299999999999999988897769753748434595763683319091796875) == 0.1 + 0.1 + 0.1

するとFalseになるという話。

おわり。(これ毎日ブログ書いてる人マジですごいと思う。)

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?