Approximate equality: Difference between revisions
Content added Content deleted
(RPL: add section) |
|||
Line 1,593: | Line 1,593: | ||
B= 100000000000000004.0 |
B= 100000000000000004.0 |
||
A approximately equal to B? true |
A approximately equal to B? true |
||
</pre> |
|||
=={{header|RPL}}== |
|||
We use here mantissa comparison, which makes that any epsilon can not be close to zero. |
|||
≪ MANT SWAP MANT - ABS 1E-09 < |
|||
≫ ‘'''CLOSE?'''’ STO |
|||
≪ {} { 100000000000000.01 100000000000000.011 |
|||
100.01 100.011 |
|||
≪ 10000000000000.001 10000 / ≫ 1000000000.0000001 |
|||
0.001 0.0010000001 |
|||
0.000000000000000000000101 0 |
|||
≪ 2 √ 2 √ * ≫ 2 |
|||
≪ 2 √ 2 √ * NEG ≫ -2 |
|||
3.14159265358979323846, π } |
|||
1 OVER SIZE '''FOR''' j |
|||
DUP j GET EVAL OVER j 1 + GET EVAL '''CLOSE?''' |
|||
NUM→ "True" "False" IFTE ROT SWAP + SWAP 2 '''STEP''' |
|||
≫ ‘'''TASK'''’ STO |
|||
{{out}} |
|||
<pre> |
|||
1: { "True" "False" "True" "False" "False" "True" "True" "True" } |
|||
</pre> |
</pre> |
||