slviajero / tinybasic

A BASIC interpreter for Arduino, ESP, RP2040, STM32, Infineon XMC and POSIX with IoT and microcontroller features.
GNU General Public License v3.0
205 stars 32 forks source link

Floating point overflow #38

Closed RonLinu closed 1 year ago

RonLinu commented 1 year ago

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

slviajero commented 1 year ago

will look into this soon. i rewrote the number code anyway

Sent from my iPhone

On Dec 5, 2022, at 10:24 PM, RonLinu @.***> wrote:

 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.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

slviajero commented 1 year ago

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.

slviajero commented 1 year ago

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