Sharp OZ-707 Operation Manual - Page 28
Relational Expressions, Logical Expressions
![]() |
UPC - 074000012141
View all Sharp OZ-707 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 28 highlights
Note: String quantities and numeric quantities cannot be combined in the same expression unless one of the functions that convert a string value into a numeric value or vice versa is used: "15" + 10 is illegal "15" + "10" is "1510", not "25" Relational Expressions A relational expression compares two expressions and determines whether the stated relationship is true or false. The relational operators are: > Greater than > = Greater than or Equal to = Equal to < > Not equal to < = Less than or Equal to < Less than The following are valid relational expressions: A = 5 0(3) < > 8 If A was equal to 10, B equal to 12, C(1,2) equal to 6, and 0(3) equal to 9, all of these relational expressions would be true. Character strings can also be compared in relational expressions. The two strings are compared character by character according to their ASCII value starting at the first character (see Appendix B). If one string is shorter than the other, a 0 or NULL will be used for any missing positions. All of the following relational expressions are true: "ABCDEF" = "ABCDEF" "ABCDEF" < > "ABCDE" "ABCDEF" > "ABCDE" Relational expressions evaluate to true or false. The Card represents true by a -1; false is represented by a O. 44 r Logical Expressions Logical operations use the Boolean algebra functions AND. OR. XOR and NOT to build connections between relational expressions. The logical operations in a single expression are evaluated after arithmetic and relational operations. In this way. logical operators can be used to make program decisions based on multiple conditions using the IF ... THEN ... ELSE statement. Example: IF A < = 32 AND B > = 90 THEN 150 This statement causes execution to jump to line number 150 if the value of the numeric variable A is less than or equal to 32 and at the same time, the value of numeric variable B is greater than or equal to 90. IF X < > 13 OR Y = 0 THEN 50 This statement causes execution to jump to line 50 unless variable X has the value 13, or if variable Y is equal to O. In a logical operation involving two numbers in the range -32768 to +32767, the two numbers are converted into 16-bit binary integers (in two's complement form) and the logical connection is then evaluated for each corresponding pair of bits in the two numbers. The results returned by the logical operators for these bit evaluations are listed here: AND OR XOR NOT XY XANDY 11 1 10 0 o1 0 00 0 XY X ORY 11 1 10 1 o1 1 00 0 XY XXORY 11 0 10 1 o1 1 00 0 X NOT X 1 0 0 1 After each bit pair has returned the corresponding result (a 1 or a 0) according to the above tables, the resulting 16-bit binary number is converted back to a decimal value. This number is the result of the logical operation. 45
![](/manual_guide/products/sharp-oz707-operation-manual-7aa0508/28.png)