``````

In [1]:

print(0.1)

``````
``````

0.1

``````
``````

In [2]:

print(format(0.1, '.20f'))

``````
``````

0.10000000000000000555

``````
``````

In [3]:

print(0.1 + 0.1 + 0.1)

``````
``````

0.30000000000000004

``````
``````

In [4]:

print(0.1 + 0.1 + 0.1 == 0.3)

``````
``````

False

``````
``````

In [5]:

print((19 / 155) * (155 / 19))

``````
``````

0.9999999999999999

``````
``````

In [6]:

print((19 / 155) * (155 / 19) == 1)

``````
``````

False

``````
``````

In [7]:

print(round(0.1 + 0.1 + 0.1, 10) == round(0.3, 10))

``````
``````

True

``````
``````

In [8]:

print(abs((0.1 + 0.1 + 0.1) - 0.3) < 1e-10)

``````
``````

True

``````
``````

In [9]:

print(1e5)

``````
``````

100000.0

``````
``````

In [10]:

print(1e-3)

``````
``````

0.001

``````
``````

In [11]:

import math

``````
``````

In [12]:

print(math.isclose(0.1 + 0.1 + 0.1, 0.3))

``````
``````

True

``````
``````

In [13]:

print(math.isclose((19 / 155) * (155 / 19), 1))

``````
``````

True

``````
``````

In [14]:

print(math.isclose(1, 1.001))

``````
``````

False

``````
``````

In [15]:

print(math.isclose(1, 1.001, rel_tol=0.01))

``````
``````

True

``````
``````

In [16]:

print(math.isclose(0, 0.001))

``````
``````

False

``````
``````

In [17]:

print(math.isclose(0, 0.001, rel_tol=0.01))

``````
``````

False

``````
``````

In [18]:

print(math.isclose(0, 0.001, abs_tol=0.01))

``````
``````

True

``````
``````

In [19]:

print(math.sin(math.pi))

``````
``````

1.2246467991473532e-16

``````
``````

In [20]:

print(math.sin(math.pi) == 0)

``````
``````

False

``````
``````

In [21]:

print(math.isclose(math.sin(math.pi), 0))

``````
``````

False

``````
``````

In [22]:

print(math.isclose(math.sin(math.pi), 0, abs_tol=1e-10))

``````
``````

True

``````
``````

In [23]:

print(round(math.sin(math.pi), 10) == 0)

``````
``````

True

``````
``````

In [24]:

print(abs(math.sin(math.pi)) < 1e-10)

``````
``````

True

``````