Difference between revisions of "TI-BASIC:And"
(Initial automated import) |
Battlesquid (talk | contribs) (code formatting) |
||
Line 12: | Line 12: | ||
'''and''' takes two numbers, variables, or expressions and tests to see if they are both True (not equal to 0). If they are, it returns 1. If either input is False (0), it returns 0. Note that the order of the operators doesn't matter (i.e. '''and''' is commutative), and that multiple '''and''''s can be used together | '''and''' takes two numbers, variables, or expressions and tests to see if they are both True (not equal to 0). If they are, it returns 1. If either input is False (0), it returns 0. Note that the order of the operators doesn't matter (i.e. '''and''' is commutative), and that multiple '''and''''s can be used together | ||
− | + | <div style="background: #FFF; border: 1px dashed #DDD; padding-left:1em; margin: 1em 0 1em 0; font-family:Arial Unicode MS; color: #000; letter-spacing:1.2pt;"> | |
:0 and 0 | :0 and 0 | ||
0 | 0 | ||
Line 28: | Line 28: | ||
:1 and 1 and 2-2 (the last input evaluates to 0, or false) | :1 and 1 and 2-2 (the last input evaluates to 0, or false) | ||
0 | 0 | ||
− | + | </div> | |
= Optimization = | = Optimization = | ||
[[TI-BASIC:Multiply|Multiplying]] two values has the same truth value as and; thus, 'and' can sometimes be replaced by multiplication. Because the calculator does implicit multiplication, meaning it automatically recognises when you want to multiply, you don't need to use the * sign. | [[TI-BASIC:Multiply|Multiplying]] two values has the same truth value as and; thus, 'and' can sometimes be replaced by multiplication. Because the calculator does implicit multiplication, meaning it automatically recognises when you want to multiply, you don't need to use the * sign. | ||
− | + | <div style="background: #FFF; border: 1px dashed #DDD; padding-left:1em; margin: 1em 0 1em 0; font-family:Arial Unicode MS; color: #000; letter-spacing:1.2pt;"> | |
:If A and B | :If A and B | ||
can be | can be | ||
:If AB | :If AB | ||
− | + | </div> | |
However, do not use this optimization if A and B might be expected to take on large values, as an overflow error might occur. | However, do not use this optimization if A and B might be expected to take on large values, as an overflow error might occur. | ||
Latest revision as of 02:32, 27 November 2017
Command Summary
Returns the logical value of value1 and value2 being true.
Command Syntax
value1 and value2
Menu Location
Press:
- 2nd TEST to access the test menu.
- RIGHT to access the LOGIC submenu.
- ENTER to select and.
TI-83/84/+/SE
1 byte
and takes two numbers, variables, or expressions and tests to see if they are both True (not equal to 0). If they are, it returns 1. If either input is False (0), it returns 0. Note that the order of the operators doesn't matter (i.e. and is commutative), and that multiple and's can be used together
:0 and 0 0 :0 and 1 0 :1 and 2 (2 counts as True, just like one) 1 :1→X :X and 2+2 (you can use variables and expressions) 1 :1 and 1 and 2-2 (the last input evaluates to 0, or false) 0
Optimization
Multiplying two values has the same truth value as and; thus, 'and' can sometimes be replaced by multiplication. Because the calculator does implicit multiplication, meaning it automatically recognises when you want to multiply, you don't need to use the * sign.
:If A and B can be :If AB
However, do not use this optimization if A and B might be expected to take on large values, as an overflow error might occur.