![]() |
<< Index >> |
FutureBasic 5 |
| Appendix D - Numeric Expressions | appendix | |
|
|
||
17.3 _true x& Z%(14)
fn theSum# fn GETCATINFO(@pb)
$". (Note: the two exceptions to this are the using function and the str# function, both of which return a string value.) len("Hello") dialog(0)
=" operator or the "<>" operator (you can also use "==" as a synonym for "=", and "!=" as a synonym for "<>"). The two operands must fall into one of the following categories:=" (or "==") is evaluated as -1 if the two operands have equal values; otherwise it's evaluated as 0. An equality comparison using "<>" (or "!=") is evaluated as -1 if the two operands are not equal; otherwise it's evaluated as 0. Examples:x& == len(acc$) * 3
"Bronson" <> theName$(7,4)
record1 = record2string1$ is considered "less than" string2$ if it precedes string2$ alphabetically. More accurately, string comparison depends on the ASCII values of the characters in the strings. An order comparison takes the form expr1 operator expr2, where expr1 and expr2 are both numeric expressions or both string expressions, and operator is one of the operators in this table:| Operator | expr1 operater expr2 returns -1 if and only if: |
| > | expr1 is greater than expr2 |
| >=, => | expr1 is greater than or equal to expr2 |
| < | expr1 is less than expr2 |
| <=, =< | expr1 is less than or equal to expr2 |
| >> (strings only) | expr1 is greater than expr2 without regard to letter case |
| << (strings only) | expr1 is less than expr2 without regard to letter case |
blt& > ham% + rye%
"hello" << mid$(testString$,x,5)+"; "-"; "not". The unary operator always appears on the left side of the operand; the operand can be any numeric expression.| Operator | Operator expr returns: |
| + | expr |
| - | the negative (additive inverse) of expr |
| Not | the binary 1's complement of expr. See Not in the main part of the manual. |
+n!
-(x# + 12 / 7.3)
not found%expr1 operator expr2 [operator expr3 ...]3 * (7 + 1)+" operator is applied before the "*" operator. 3 is multiplied by the sum of 7 and 1, giving a result of 24. But if the expression had been written like this:3 * 7 + 1*" operator would have been applied first. In this case, 1 is added to the product of 3 and 7, giving a result of 22.| Operator | Description |
| + | Addition. |
| ++ | Increment a variable |
| += | Add the expression from the right of the equal sign to the variable on the left. |
| - | Subtraction |
| -- | Decrement a variable |
| -= | Subtract the expression from the right of the equal sign from the variable on the left. |
| * | Multiplication. |
| / | If both operands are integer expressions, this operator does integer division. If either operand is a real number, the operator does floating point division. |
| \ | The operator always does floating point division. Integer operands are converted to floating point before the division. |
| \\ | Identical to / |
| ^ | Exponentiation (raising to a power). |
| =; == | Comparison. |
| << | The first operand is shifted left by the number of bit positions specified by the second operand. Both operands must be integral values. A left shift by n is equivalent to multiplying by 2^n. The result is undefined if n is negative or greater than the width in bits of the first operand. |
| >> | The first operand is shifted right by the number of bit positions specified by the second operand. Both operands must be integral values. A right shift by n is equivalent to dividing by 2^n with rounding towards minus infinity. The result is undefined if n is negative or greater than the width in bits of the first operand. |
| And; && | Bitwise And operator. See the description in the main part of the manual. |
| Nand; ^& | Bitwise Not And operator. See the description in the main part of the manual. |
| Or; || | Bitwise Or operator. See the description in the main part of the manual. |
| Nor; ^| | Bitwise Not Or operator. See the description in the main part of the manual. |
| Xor; ^^ | Bitwise Xor operator. See the description in the main part of the manual. |
| Mod | Modulus operator. See the description in the main part of the manual. |
7 + 3 + 6 * 18.7
x& and (not bit(7))
ZZ mod (x% + 8)4 + 7 * 5*" operator has a higher precedence than the "+" operator (see the table below). So, when this expression is evaluated, first 7 is multiplied by 5 to get 35; then that result is added to 4 to get the final answer of 39.| Precedence level | Operator |
| 1 | unary "+"; unary "-"; Not |
| 2 | ^ |
| 3 | *; /; \; \\; Mod |
| 4 | + (addition); - (substraction) |
| 5 | <; <=; >; >=; =; ==; <>; != << (strings); >> (strings) |
| 6 | << (shift left); >> (shift right) |
| 7 | And; Or; Xor; Nand; Nor |
20 - 4 + 3 * (24 / (7 + 1) + 2)|
Operation |
Resulting expression |
|
20-4 = 16 |
16 + 3 * (24 / (7 + 1) + 2) |
|
(7+1) = 8 |
16 + 3 * (24 / 8 + 2) |
|
24/8 = 3 |
16 + 3 * (3 + 2) |
|
(3+2) = 5 |
16 + 3 * 5 |
|
3*5 = 15 |
16 + 15 |
| 16 + 15 = 31 | 31 |
sizeof, offsetof and typeof functions.
762
3 * _myConstant + sizeof(x&)
44 / 11126 + x&
3.14159
sqr(49)
85 + fn Zilch(36)str$() function. An identical conversion occurs when you print a floating point value.gFBFloatMaxDigits = 3 // or 15 or whatever