Issue with default rounding numbers in Processing Java Mode

Next time please insert code with </>. You’ll get more answers when people don’t have to type your code, instead of copying it from code section.

Calculation of b. Because you use only integer values calculations are done as integers and result zero is then stored to b as float. If you change the first line to

float b=(10+(500/1000.0))/60;

It’s a common practise to use explicit float value as divider.

Second problem comes from how floating point numbers are presented internally. They are not accurate, they can be slightly off like value of a 13.049999.

1 Like