wrong result in javasript equation

I have a simple health upgrade in my project and wen i want to upgrade my health it writes in label my next upgrade bonus. This is my code

> var basic_hp : float;
> var next_hp : float;
> var bonus : float;
> basic_hp = 200;
> next_hp = basic_hp*1.2;
> bonus=next_hp-basic_hp;
> debug.log(bonus);

and in debug log bonus is 40,00002 anyone know why?

It’s a round error due to the float declaration. Can’t you declare those variables as integers? I don’t think that you want decimal values for health parameters.