inkle / ink

inkle's open source scripting language for writing interactive narrative.
http://www.inklestudios.com/ink
MIT License
3.97k stars 482 forks source link

unexpected rounding for int/float division #863

Open machinex7 opened 9 months ago

machinex7 commented 9 months ago

When I evaluate the following expression, I get a result of "-0" { -1.0 * 5 / 1000 }

But when I instead simplify the first multiplication myself, I get the expected result of "-0.005" { -5.0 / 1000 }

As a workaround I figured out I can do the first multiplication and store the result in a temp variable, and then use that for the subsequent calculation, but it would be nice if it handled the math for me. Seems like it could introduce other mathematical bugs down the road. I'm using Inky version: 0.14.1

Thanks!

JacobChrist commented 9 months ago

Can you add parentheses?

{ (-1.0 * 5) / 1000 }

Don't know if this will work but it may be worth a try.