I thought I'd post just one word and wrote it. In a nutshell, if you want an integer solution for division, use "//" or "divmod".
Divide the number by 100 to get an integer.
result = int(value / 100)
Well, in most cases this works. However, it is NG with a large number.
>>> 38030123828366199/100
380301238283662.0
It's easy to understand.
result = value // 100
>>> 38030123828366199 // 100
380301238283661
So, I wanted to see the boundary.
>>> 38030123828366199/100
380301238283662.0
>>> 38030123828366198/100
380301238283662.0
>>> 38030123828366197/100
380301238283662.0
>>> 38030123828366196/100
380301238283661.94
>>> 38030123828366195/100
380301238283661.94
>>> 38030123828366194/100
380301238283661.94
>>> 38030123828366193/100
380301238283661.94
>>> 38030123828366192/100
380301238283661.94
>>> 38030123828366191/100
380301238283661.94
>>> 38030123828366190/100
380301238283661.9
>>> 38030123828366189/100
380301238283661.9
I see, it's easy to understand. Depending on the mood of the last bit, it takes a discrete value. of course it is.
It's the same as the number of floating point numbers that can be held just before the limit is even. Let's be aware of the calculation accuracy. .. ..
Recommended Posts