Fix a divide by 0 bug in `root()` (lib2.bc)
This commit is contained in:
parent
1818b894e0
commit
0c1abbe6df
|
@ -110,7 +110,7 @@ define root(x,n){
|
|||
if(n<0)sqrt(n)
|
||||
n=n$
|
||||
if(n==0)x/n
|
||||
if(n==1)return x
|
||||
if(x==0||n==1)return x
|
||||
if(n==2)return sqrt(x)
|
||||
s=scale
|
||||
scale=0
|
||||
|
|
|
@ -84,6 +84,12 @@ cbrt(27)
|
|||
cbrt(-27)
|
||||
cbrt(4096)
|
||||
cbrt(-4096)
|
||||
root(0, 3)
|
||||
root(0, 4)
|
||||
root(0, 5)
|
||||
root(0.0000000000000, 3)
|
||||
root(0.0000000000000, 4)
|
||||
root(0.0000000000000, 5)
|
||||
root(16, 4)
|
||||
root(3125, 5)
|
||||
root(-3125, 5)
|
||||
|
|
|
@ -84,6 +84,12 @@
|
|||
-3.00000000000000000000
|
||||
16.00000000000000000000
|
||||
-16.00000000000000000000
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
2.00000000000000000000
|
||||
5.00000000000000000000
|
||||
-5.00000000000000000000
|
||||
|
|
Loadingâ¦
Reference in New Issue