summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2024-03-27Fix float to integer conversionNicolas Schodet
When converting a float to an integer, if the integer is not able to represent the value, the behavior is implementation defined. The original firmware source code depends on this implementation defined behavior from the C compiler. The LEGO MINDSTORMS NXT Executable File Specification does not define what is the expected behavior for the firmware because it was released for version 1.03, before float was supported. However it says: "At the scalar level, data type conversions behave identically to type casts in ANSI C.". For NXT Improved Firmware, I decided to follow the behavior of the original firmware binary, which is: - Negative values to unsigned numbers: large positive integer (two's complement). - Round to nearest for SETOUT instruction, truncate for other operations.
2024-03-08Change to version 1.29.51.29.5Nicolas Schodet
2024-03-08Fix signed float to int conversionNicolas Schodet
This can be visible using this test: task main() { float a = -12.34; NumOut(0, 32, a); char b = a; NumOut(0, 24, b); Wait(3000); } Thanks to Andreas Weber for reporting the problem and for the test program. This was actually fixed in NXT Enhanced Firmware, not sure if it was by accident or not as the original firmware source code comment suggests that special casing this conversion could improve speed. Imported from NXT Enhanced Firmware.
2024-03-05Change to version 1.29.41.29.4Nicolas Schodet
2023-03-06Change to version 1.29.31.29.3Nicolas Schodet
2023-03-06Simplify source treeNicolas Schodet
Now just use make in the root directory to build.