HEEELP with 2.05/0.05 rez 40.99999999 WHYYY?

I cant understand why it happens.
open console and type there:
let a = 2.05/0.05
and i got the rezult
40.99999999999999 ???

a = 2.10/0.05
will give me rezult

a = 0.15/0.05

How it happens ? and what i need to write to get the calc rezults (0.15/0.05 must be 3 )???

See this:


You are a victim of floating point precision errors, see this site for some basic explanations of them:


Instead of floating point calculations, you can use fixed point with libraries like bignum or handle the precision yourselves

1 Like

Thank u for ur answers. They help me very much.