Old Basic bug in the val() function

Evaluating VAL(“E39”) corrupts the program, here’s a timestamped link to the YouTube video, the video before it just shows the basics (haha) of how VAL() works.

2 Likes

But it was fixed in BASIC-80 Rev. 5.21 of 28-Jul-81 (aka MBASIC for CP/M-80). And of course, the completely different floating point system used in MSX BASIC didn’t complain at all.

1 Like

One could argue that the error being caused by the floating point parsing/overflow was somewhat irrelevant since more generally the problem was that in the case of an error the in-place temporarily modified token was left modified. It could have been any error, it was the handling of an error condition that was faulty.

Also the video reminded me of the mercurial nature of parsing: see a digit, start parsing a number, and the result might be an integer, a floating point number, an overflow, a bigint, a fixed point number, depending on what your language can handle.