Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Approximate-equality/Zkl/approximate-equality.zkl
Normal file
17
Task/Approximate-equality/Zkl/approximate-equality.zkl
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
testValues:=T(
|
||||
T(100000000000000.01,100000000000000.011),
|
||||
T(100.01, 100.011),
|
||||
T(10000000000000.001 / 10000.0, 1000000000.0000001),
|
||||
T(0.001, 0.0010000001),
|
||||
T(0.00000000000000000101, 0.0),
|
||||
T( (2.0).sqrt()*(2.0).sqrt(), 2.0),
|
||||
T( -(2.0).sqrt()*(2.0).sqrt(), -2.0),
|
||||
T(100000000000000003.0, 100000000000000004.0),
|
||||
T(3.14159265358979323846, 3.14159265358979324)
|
||||
);
|
||||
|
||||
tolerance:=-1e-9; // <0 for relative comparison
|
||||
foreach x,y in (testValues){
|
||||
maybeNot:=( if(x.closeTo(y,tolerance)) " \u2248" else "!\u2248" );
|
||||
println("% 25.19g %s %- 25.19g %g".fmt(x,maybeNot,y, (x-y).abs()));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue