aanon4 / BlueBasic

BASIC interpreter for CC2540 and CC2541 Bluetooth LE chips
https://gitlab.com/timwilkinson/BlueBasic
97 stars 55 forks source link

Large numbers > 536870912 (1<<29) are wrongly computed #32

Closed kscheff closed 7 years ago

kscheff commented 7 years ago

Large numbers result in wrong values, e.g.

PRINT 1<<29
536870912
OK
PRINT 1<<29+1
761419044
OK

In some circumstances this crashes the system. One example is the millis() function:

CONFIG MILLIS, 1<<31
OK
PRINT MILLIS()
... system not responding anymore

This means when using millis() the time counter gets corrupted during day 373 (after 536870912 ms). This might be an issue for IoT applications running extend periods of time and using millis() for time reference.

kscheff commented 7 years ago

The issue was in the printnum() routine of the BASIC interpreter. A fixed version to be found here: https://github.com/kscheff/BlueBasic/commit/ea6598298e58bdb701b0b3c5fc8e0abfe92fa28f