
Linux Format forums Help, discussion, magazine feedback and more

View previous topic :: View next topic 
Author 
Message 
purplepenguin LXF regular
Joined: Wed Oct 05, 2011 3:19 pm Posts: 109 Location: Blissfully at the Command Line

Posted: Tue Dec 04, 2012 5:11 pm Post subject: Boolean logic conundrum 


Hi, I wonder if someone would be so kind as to help me out?
I'm writing a Sense program for my HND at the OU and I'm not sure if I'm being stupid or whether I've spotted a typo. I wanted to check with people in the know before I email my tutor.
The task tells me:
Place the sprite at x:0 and y:170
So long as the y position of sprite is greater than or equals to 175 it should move down the stage in 1 step intervals.
To my mind if the sprite's y position is equal to 175 it should continue to move and end up at 176.
Later on i am told that the sprite should not exceed 175
How can the sprite be equal to 175 and still move 1 place down but not exceed 175.
Thank you for your patience 

Back to top 


greg.d
Joined: Thu Oct 27, 2005 9:29 am Posts: 24

Posted: Tue Dec 04, 2012 8:48 pm Post subject: 


So 175 is the lowest value? I dont know what they mean by move down the stage? Maybe that means the X axis?
So do they mean move X by 1, and Y by 1 each time until Y=175? 

Back to top 


guy LXF regular
Joined: Thu Apr 07, 2005 1:07 pm Posts: 1041 Location: Worcestershire

Posted: Tue Dec 04, 2012 9:05 pm Post subject: 


You are right, the logic is faulty. Worse, it is ambiguous and both interpretations are still faulty!
If it moves when Y is "greater than or equal to" 175 then it should move until eventually Y becomes less than 175, i.e. 176. Then it should stop.
"The sprite should not exceed 175" is unclear, since "exceed" is not mathematically defined. However, both possible meanings are wrong.
If "exceed" means "greater than" as in 170 exceeds 175, then that would lead to an incorrect statement, since the starting point well exceeds the stated limit.
If "exceed" means "have greater magnitude than" as in 175 has greater magnitude than 170, then that would also be incorrect, since as we have seen the sprite must pass through 175 and stop at 176.
However, the faulty logic is not Boolean, it is arithmetical. _________________ Cheers,
Guy
The eternal help vampire 

Back to top 


Dutch_Master LXF regular
Joined: Tue Mar 27, 2007 2:49 am Posts: 2422

Posted: Wed Dec 05, 2012 2:25 am Post subject: 


FYI: this is not Boolean, it's maths 

Back to top 


purplepenguin LXF regular
Joined: Wed Oct 05, 2011 3:19 pm Posts: 109 Location: Blissfully at the Command Line

Posted: Wed Dec 05, 2012 7:11 pm Post subject: 


Hi Guy
Thank you for your explanation, just as I thought although I was starting to doubt myself and wonder if I was missing something obvious.
I was getting all wrapped up with Boolean logic as we have just covered <, >, =, and, or and not operators the OU explained these as Boolean Logic operators. I now see the error is a mathematical one.
I have sent an email to my tutor. I am now wondering if maybe it was intentional to see if we are paying attention.
Thank you once again. 

Back to top 


guy LXF regular
Joined: Thu Apr 07, 2005 1:07 pm Posts: 1041 Location: Worcestershire

Posted: Wed Dec 05, 2012 7:58 pm Post subject: 


Well, < and > are not usually regarded as Boolean operators  especially on a beginners' course. AND, OR, NOT and so on are the usual suspects.
However I seem to recall that some Boolean algebras incorporate them as well. I suppose that = is trivially Boolean.
@Dutch_Master, Is logic a branch of maths or is maths a branch of logic? The answer of course depends on whether you ask a logician or a mathematician. _________________ Cheers,
Guy
The eternal help vampire 

Back to top 


AndyBaxman LXF regular
Joined: Tue Oct 04, 2005 9:47 am Posts: 523

Posted: Mon Dec 10, 2012 1:02 pm Post subject: 


purplepenguin wrote: 
I was getting all wrapped up with Boolean logic as we have just covered <, >, =, and, or and not operators the OU explained these as Boolean Logic operators. I now see the error is a mathematical one. 
Comparison operators (==, >, <, <=, >=, ===, etc, depending on language) are not boolean operators as they can take non boolean operands, but they do always return a boolean result.
Only the equality operator makes any sense with Boolean operands, and then only if you are comparing two boolean variables (i.e. not literals). (boolvar1 == boolvar2) will return true if, and only if, both variables are true or both variables are false (i.e. the same)
Cases like (boolvar1 == true) are nonsensical as
IF boolvar1 == 1 THEN .....
is equivalent to
IF boolvar1 THEN ..... _________________ Bomb #20: "Let there be light" 

Back to top 


View previous topic :: View next topic 


You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group

