Would anyone mind explaining how to use boolean logic? I have read up on it, and it sort of makes sense, but not really.
Thanks!
I would love to help, but first, could give some more information on what exactly you're doing this work? What programming language and for what will you be programming for?
This would be for TI-Basic. I am working on expanding my knowledge of programming my calculator, and I have found that boolean logic has shown up in a lot of programs, and I would like to learn how to use it.
AND means both must be true.
ie:
Code:
1+1=2 AND 2+1=3

OR means one must be true.
ie:

Code:
1+1=3 OR 1+1=2

NOR means both must be false.
ie:

Code:
1+1=3 NOR 1+1=4

NOT means that the specified condition must be false.
ie:

Code:
1+1=2 NOT 1+1=3
Thanks, that is helpful, but I already know most of the things about those types of logic gates, did a presentation on them for communications merit badge. I think that what I am actually looking for are Piecewise Expressions(http://tibasicdev.wikidot.com/piecewise-expressions). Thanks for your help though!
Expanding on what Firepup said:

Original:

Code:

If 1+1=2 AND 2+2=3:Disp "Hey there"

The output would be "Hey there", since both are true.

Correct:

Code:

If 1+1=2 AND 1+2=3:Disp "Hey there"

The output would be "Hey there", since both are true. No, 2+2 does not equal 3 Razz


Code:

If 1+1=1 OR 1+1=1:Disp "This is odd"

There would be no output since neither are true, but if you did this:

Code:

If 1+1=2 OR 1+1=1:Disp "This is odd"

The output would be "This is odd" since one is true. This also works:

Code:

If 1+1=2 OR 1+2=3:Disp "Yay calcs"

We get "Yay calcs" because OR can work when at least one is true, but also when multiple are true.


Code:

If 1+1=8 XOR 1+1=2:Disp "Yay"

Output is "Yay", since one is true. XOR is like OR, but it means exclusive or. This means that only ONE can be true, not both. With OR, at least one must be true, but both can be true as well. For example:

Code:

If 1+1=2 XOR 3+2=5:Disp "Sad"

There is no output since both are true.

Code:

If 1+1=5 NOR 1+1=6:Disp "NOR is an operator"

Output is "NOR is an operator" because neither is true. If you did this:

Code:

If 1+1=2 NOR 2+1=1:Disp "Hello"

or this:

Code:

If 1+1=2 NOR 2+2=4:Disp "Hello"

there is no output since either one or both is true. (I don't think NOR is in TI-BASIC)


Code:

If not(1+1=2):Disp "yo"

In TI-BASIC, not is used differently. There is no output here since 1+1=2 is true. If we did this:

Code:

If not(1+2=8):Disp "TIny is cool"

We get the output "TIny is cool" because TIny is cool 1+2=8 is false.


EDIT
Didn't see the previous post Razz
Firepup650 wrote:

NOT means that the specified condition must be false.
ie:
Code:
1+1=2 NOT 1+1=3


Isn't the NOT operator unary?
as in

Code:

If Not a:
 Then
  blah
 EndIf
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
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

 

Advertisement