Difference between revisions of "%="
From WikiManual
m (→Percent Equals) |
(rewrite and explanation on limit cases) |
||
| Line 1: | Line 1: | ||
| − | == | + | '''<code>%=</code>''' and '''<code>!%=</code>''' are approximate equality operators. |
| − | When the two values placed on the stack are within 10% of | + | When the two values placed on the stack are within 10% of the first one (chronologically), <code>%=</code> places a "true" on the conditions stack. <code>!%=</code> returns the opposite of <code>%=</code> and is equivalent to <code>%= [[not]]</code>. |
| − | Example: | + | ;Example:<code>50 55 %=</code> will place "true" on the conditions stack. |
| − | + | == More details == | |
| − | + | In VisualBasic, the actual operation used to handle <code>a b %=</code> is (equivalent to) <code>Abs(a - b) <= a/10</code>, where all operations are performed on Single-precision integers. Therefore, <code>9 10 %=</code> is false because 9/10 evaluates to 0, while <code>10 9 %=</code> is true because 10/10 evaluates to 1. | |
{{Logical Comparison Operators}} | {{Logical Comparison Operators}} | ||
Latest revision as of 21:45, 20 January 2007
%= and !%= are approximate equality operators.
When the two values placed on the stack are within 10% of the first one (chronologically), %= places a "true" on the conditions stack. !%= returns the opposite of %= and is equivalent to %= not.
- Example
50 55 %=will place "true" on the conditions stack.
More details
In VisualBasic, the actual operation used to handle a b %= is (equivalent to) Abs(a - b) <= a/10, where all operations are performed on Single-precision integers. Therefore, 9 10 %= is false because 9/10 evaluates to 0, while 10 9 %= is true because 10/10 evaluates to 1.
Logical Comparison Operators:
|