Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Approximate-equality/Sidef/approximate-equality-1.sidef
Normal file
16
Task/Approximate-equality/Sidef/approximate-equality-1.sidef
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[
|
||||
100000000000000.01, 100000000000000.011,
|
||||
100.01, 100.011,
|
||||
10000000000000.001 / 10000.0, 1000000000.0000001000,
|
||||
0.001, 0.0010000001,
|
||||
0.000000000000000000000101, 0.0,
|
||||
sqrt(2) * sqrt(2), 2.0,
|
||||
-sqrt(2) * sqrt(2), -2.0,
|
||||
sqrt(-2) * sqrt(-2), -2.0,
|
||||
cbrt(3)**3, 3,
|
||||
cbrt(-3)**3, -3,
|
||||
100000000000000003.0, 100000000000000004.0,
|
||||
3.14159265358979323846, 3.14159265358979324
|
||||
].each_slice(2, {|a,b|
|
||||
say ("#{a} ≅ #{b}: ", a ≅ b)
|
||||
})
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
var a = 100000000000000.01
|
||||
var b = 100000000000000.011
|
||||
|
||||
# Rounding at 2 and 3 decimal places, respectively
|
||||
say (round(a, -2) == round(b, -2)) # true
|
||||
say (round(a, -3) == round(b, -3)) # false
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
var a = 22/7
|
||||
var b = Num.pi
|
||||
|
||||
say ("22/7 ≅ π at 2 decimals: ", approx_cmp(a, b, -2) == 0)
|
||||
say ("22/7 ≅ π at 3 decimals: ", approx_cmp(a, b, -3) == 0)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
say (1.33333333.rat_approx == 4/3) # true
|
||||
say (zeta(-5).rat_approx == -1/252) # true
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
for k in (3..19) {
|
||||
var r = Str(Num.pi).first(k)
|
||||
say ("rat_approx(#{r}) = ", Num(r).rat_approx.as_frac)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue