I'm completely new to Simba so i'm not sure if it's a syntax thing but the following evaluates to false
Writeln(47 >= 40 and 47 < 60);
why is this false?
47 is greater than or equal to 40 and 47 is less than 60
I'm completely new to Simba so i'm not sure if it's a syntax thing but the following evaluates to false
Writeln(47 >= 40 and 47 < 60);
why is this false?
47 is greater than or equal to 40 and 47 is less than 60
You need parenthesis around each condition.
Simba Code:writeln((47 >= 40) and (47 < 60));
47 >= 40 = 1.
1 and 47 = 0. //Bitwise AND.
0 < 60 = 1.
True.
47 >= 40 = 1.
1 and 47 = 1. //Logical AND.
1 < 60 = 1.
True.
47 >= 40 = 1.
47 < 60 = 1.
1 and 1 = 1. //Both Bitwise & Logical.
True.
40 and 47 = 40. //Bitwise AND.
47 >= 40 = 1.
1 < 60 = 1.
True.
40 and 47 = 40. //Bitwise AND.
40 < 60 = 1.
47 >= 1.
True.
40 and 47 = 1. //Logical AND.
47 >= 1 = 1.
1 < 60 = 1.
True.
In Pascal, operator AND takes precedence over comparator operators.
//First
47 >= 40 and 47 < 60.
47 >= 40 < 60.
47 >= 40 = true || 40 < 60 = true.
//Last
47 >= 40 = 1.
47 < 60 = 1.
1 and 1 = true.
Thus the statement holds true even if you do the AND operator first or last.
Can't see a case in which the above should ever evaluate false.
Last edited by Brandon; 12-24-2016 at 02:12 AM.
I am Ggzz..
Hackintosher
There are currently 1 users browsing this thread. (0 members and 1 guests)