gen.codebox math issues

Sukandar Kartadinata's icon

I have a codebox with this "formula"

out1 = 1874890000 * 10;

when I bang it I get 1569030816. So this smells like a 32-bit resolution problem.

When I replace the 10 with an inlet and supply the value of 10 from outside it works though.

out1 = 18748900000 * in1;

=> 18748900000

This doesn't change things btw

out1 = 1874890000.0 * 10.0;

=> 1569030816

👽!t W∆s ∆lienz!👽's icon

It's some kind of internal optimization thing causing the compiler to pre-calculate static numbers like that as 32-bit numbers before runtime.

Instead, use 'History' to trick gen so it calculates at runtime as a 64-bit float:

History val(1874890000);
out1 = val * 10;

This is why your 'in1' trick worked, too.

Sukandar Kartadinata's icon

Thanks much, this worked.

Would be nice though if didn't have to worry about 32-bit cruft anymore...