Liberty BASIC Community Forum
« expression in an IF/THEN statement is a floating »

Welcome Guest. Please Login or Register.
Feb 24th, 2018, 12:00am

Rules|Home|Help|Search|Recent Posts|Notification

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: expression in an IF/THEN statement is a floating  (Read 573 times)
Board Moderator

member is offline


Anatoly (real name)


Gender: Male
Posts: 1745
xx 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
-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?
User IP Logged

damned Dog in the Manger
Chris Iverson

member is offline


20% Cooler

Homepage PM

Gender: Male
Posts: 2310
xx Re: expression in an IF/THEN statement is a floati
« Reply #1 on: Dec 1st, 2014, 12:49pm »

This was probably the quickest way of eliminating the crash. I'd imagine discussion is still available on the exact behavior.
User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls