Casting float to integer in LitterBox translation
To resolve a bug that - when translating a Scratch program that has floating points in "change x by", "change y by", it gives an error: Exception in thread "main" java.lang.RuntimeException: Expected type integer but got 5.5, we have casted all float literals to int unless expectFloat is explicit.
However, this may have caused us to cast some that are not supposed to be integers to integers. So please let us know if there are other ways to change the translation method.
Thank you for your pull request!
However, this may have caused us to cast some that are not supposed to be integers to integers. So please let us know if there are other ways to change the translation method.
You are right here - you propose to use integer even if the ORIGINAL type is expected - we suggest to round floats to ints only if it is explicitly expected.
Furthermore, casting floats to ints cuts off the decimal places instead of rounding. That results in unneccessary imprecision and we suggest to use round() instead of casts.
In the long term we also consider to allow floats for the "change x by" and "change y by" blocks, as rounding floats in general discards relevant information, so why not keep it :smile: