0
0

Pythonで浮動小数点を出力してみる

Last updated at Posted at 2024-05-03
% python
Python 3.9.9
>>> print(0.1 + 0.2)
0.30000000000000004
>>> print(0.1 * 0.2)
0.020000000000000004
>>> print(0.3 / 0.1)
2.9999999999999996
>>> print(0.3 / 0.1 * 0.01)
0.029999999999999995
>>> print(0.3 / 0.1 * 0.00001)
2.9999999999999997e-05
>>> print(0.3 / 0.1)
2.9999999999999996
>>> print(0.3 / 0.1 * 0.1)
0.3
>>> print(0.3 / 0.1 * 0.01)
0.029999999999999995
>>> print(0.3 / 0.1 * 0.001)
0.0029999999999999996
>>> print(0.3 / 0.1 * 0.0001)
0.0003
>>> print(0.3 / 0.1 * 0.00001)
2.9999999999999997e-05
>>> print(0.3 / 0.1 * 0.000001)
2.9999999999999992e-06
0
0
1

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
0
0