expression in an IF/THEN statement is a floating
« Thread started on: Dec 1st, 2014, 12:40pm »
Sorry I have no idea what room it should be asked. So. LB4.5b1 release notice says Quote:
-Eliminated a runtime error "asBoolean not understood" for when the result of a comparison expression in an IF/THEN statement is a floating point value. For example:
if 1/2 then print "testing"
Now the value is truncated to an integer if needed. This means that if the result of the expression is 1 > n > -1 then the expression will evaluate to false.
I wonder what is the reasoning behind this decision? I mean, having program behave somehow instead of dying with error message is nice, but why exactly truncate to integer so 1 > n > -1 gives false? Just for comparison, Quick Basic considers only 0 to be false. Of another languages that allow number for IF expression, I tried two C compilers - and both consider 0 to be false, and +/- 0.2 to be true (well, it was TinyC compiler and old Borland Turbo C, I'll try with Microsoft C later on).
I mean - while it's new feature, it might be possible/worth to change this behavior?