Integer division returning a different result than expected

I am having a problem with integer division in python and R. The language returns a different value from the "correct" in the entire division of 327 by 3.27 and the rest(%) different from 0 in these cases. (The image is python, but in R you get the same values, as I tested on my machine) Image

Author: MateusAnselmo, 2020-05-28

1 answers

The problem is that the computer is not very accurate, it's like you try to store 1/3 (it does not have as PQ is an infinite decimal number, so it rounds and loses accuracy).

On this site explains best in the "Quick word on Floating Point Arithmetic Issues"session.

What I did was multiply the value by 100 and then divide, because so it ceases to be decimal and becomes integer.

Example of my code

 2
Author: Henrique Resende, 2020-05-28 01:11:00