slviajero / tinybasic

A BASIC interpreter for Arduino, ESP, RP2040, STM32, Infineon XMC and POSIX with IoT and microcontroller features.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Floating point overflow

RonLinu opened this issue · comments

Hello Stefan!
I guess you probably know about this but here it is: TinyBASIC locks up when handling a number bigger than 1e38.
print 1e39
x = 1e39
will lock up the interpreter.
I admit this does not occur often, mostly because of a programming error.

On the other hand, underflow is handled correctly as it returns 'zero' which is ok.

Tested on an Arduino Mega 2560

Checked in new code in the TinybasicArduino folder of the repo that fixes the problem. Origin is mishandling of inf. The code I checked in is portable to gcc variants. Will ceck portability.

Fixed now in the main code and tested against the main platforms. Handle inf and nan.