Difference between revisions of "%="

From WikiManual
Jump to: navigation, search
(Logical Comparison Operators)
(rewrite and explanation on limit cases)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
== Percent Equals ==
+
'''<code>%=</code>''' and '''<code>!%=</code>''' are approximate equality operators.
  
When the two values placed on the stack are within 10% of each other this places a "true" on the conditions stack.
+
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.
  
50 55 %=
+
== More details ==
  
will place "true" on the conditions stack.
+
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:

> <
>= <=
= !=
%= !%=
~= !~=