summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/bc.c344
1 files changed, 172 insertions, 172 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 45680c1..866fa30 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -919,178 +919,178 @@ static const char bc_program_stdin_name[] = "<stdin>";
static const char *bc_lib_name = "gen/lib.bc";
static const char bc_lib[] = {
- "scale=20"
-"\ndefine e(x){"
-"\n auto b,s,n,r,d,i,p,f,v"
-"\n b=ibase"
-"\n ibase=A"
-"\n if(x<0){"
-"\n n=1"
-"\n x=-x"
-"\n }"
-"\n s=scale"
-"\n r=6+s+0.44*x"
-"\n scale=scale(x)+1"
-"\n while(x>1){"
-"\n d+=1"
-"\n x/=2"
-"\n scale+=1"
-"\n }"
-"\n scale=r"
-"\n r=x+1"
-"\n p=x"
-"\n f=v=1"
-"\n for(i=2;v!=0;++i){"
-"\n p*=x"
-"\n f*=i"
-"\n v=p/f"
-"\n r+=v"
-"\n }"
-"\n while((d--)!=0)r*=r"
-"\n scale=s"
-"\n ibase=b"
-"\n if(n!=0)return(1/r)"
-"\n return(r/1)"
-"\n}"
-"\ndefine l(x){"
-"\n auto b,s,r,p,a,q,i,v"
-"\n b=ibase"
-"\n ibase=A"
-"\n if(x<=0){"
-"\n r=(1-10^scale)/1"
-"\n ibase=b"
-"\n return(r)"
-"\n }"
-"\n s=scale"
-"\n scale+=6"
-"\n p=2"
-"\n while(x>=2){"
-"\n p*=2"
-"\n x=sqrt(x)"
-"\n }"
-"\n while(x<=0.5){"
-"\n p*=2"
-"\n x=sqrt(x)"
-"\n }"
-"\n r=a=(x-1)/(x+1)"
-"\n q=a*a"
-"\n v=1"
-"\n for(i=3;v!=0;i+=2){"
-"\n a*=q"
-"\n v=a/i"
-"\n r+=v"
-"\n }"
-"\n r*=p"
-"\n scale=s"
-"\n ibase=b"
-"\n return(r/1)"
-"\n}"
-"\ndefine s(x){"
-"\n auto b,s,r,n,a,q,i"
-"\n b=ibase"
-"\n ibase=A"
-"\n s=scale"
-"\n scale=1.1*s+2"
-"\n a=a(1)"
-"\n if(x<0){"
-"\n n=1"
-"\n x=-x"
-"\n }"
-"\n scale=0"
-"\n q=(x/a+2)/4"
-"\n x=x-4*q*a"
-"\n if(q%2!=0)x=-x"
-"\n scale=s+2"
-"\n r=a=x"
-"\n q=-x*x"
-"\n for(i=3;a!=0;i+=2){"
-"\n a*=q/(i*(i-1))"
-"\n r+=a"
-"\n }"
-"\n scale=s"
-"\n ibase=b"
-"\n if(n!=0)return(-r/1)"
-"\n return(r/1)"
-"\n}"
-"\ndefine c(x){"
-"\n auto b,s"
-"\n b=ibase"
-"\n ibase=A"
-"\n s=scale"
-"\n scale*=1.2"
-"\n x=s(2*a(1)+x)"
-"\n scale=s"
-"\n ibase=b"
-"\n return(x/1)"
-"\n}"
-"\ndefine a(x){"
-"\n auto b,s,r,n,a,m,t,f,i,u"
-"\n b=ibase"
-"\n ibase=A"
-"\n n=1"
-"\n if(x<0){"
-"\n n=-1"
-"\n x=-x"
-"\n }"
-"\n if(x==1){"
-"\n if(scale<65){"
-"\n return(.7853981633974483096156608458198757210492923498437764552437361480/n)"
-"\n }"
-"\n }"
-"\n if(x==.2){"
-"\n if(scale<65){"
-"\n return(.1973955598498807583700497651947902934475851037878521015176889402/n)"
-"\n }"
-"\n }"
-"\n s=scale"
-"\n if(x>.2){"
-"\n scale+=5"
-"\n a=a(.2)"
-"\n }"
-"\n scale=s+3"
-"\n while(x>.2){"
-"\n m+=1"
-"\n x=(x-.2)/(1+.2*x)"
-"\n }"
-"\n r=u=x"
-"\n f=-x*x"
-"\n t=1"
-"\n for(i=3;t!=0;i+=2){"
-"\n u*=f"
-"\n t=u/i"
-"\n r+=t"
-"\n }"
-"\n scale=s"
-"\n ibase=b"
-"\n return((m*a+r)/n)"
-"\n}"
-"\ndefine j(n,x){"
-"\n auto b,s,o,a,i,v,f"
-"\n b=ibase"
-"\n ibase=A"
-"\n s=scale"
-"\n scale=0"
-"\n n/=1"
-"\n if(n<0){"
-"\n n=-n"
-"\n if(n%2==1)o=1"
-"\n }"
-"\n a=1"
-"\n for(i=2;i<=n;++i)a*=i"
-"\n scale=1.5*s"
-"\n a=(x^n)/2^n/a"
-"\n r=v=1"
-"\n f=-x*x/4"
-"\n scale=scale+length(a)-scale(a)"
-"\n for(i=1;v!=0;++i){"
-"\n v=v*f/i/(n+i)"
-"\n r+=v"
-"\n }"
-"\n scale=s"
-"\n ibase=b"
-"\n if(o!=0)a=-a"
-"\n return(a*r/1)"
-"\n}"
+ "scale=20"
+"\n" "define e(x){"
+"\n" "auto b,s,n,r,d,i,p,f,v"
+"\n" "b=ibase"
+"\n" "ibase=A"
+"\n" "if(x<0){"
+"\n" "n=1"
+"\n" "x=-x"
+"\n" "}"
+"\n" "s=scale"
+"\n" "r=6+s+0.44*x"
+"\n" "scale=scale(x)+1"
+"\n" "while(x>1){"
+"\n" "d+=1"
+"\n" "x/=2"
+"\n" "scale+=1"
+"\n" "}"
+"\n" "scale=r"
+"\n" "r=x+1"
+"\n" "p=x"
+"\n" "f=v=1"
+"\n" "for(i=2;v!=0;++i){"
+"\n" "p*=x"
+"\n" "f*=i"
+"\n" "v=p/f"
+"\n" "r+=v"
+"\n" "}"
+"\n" "while((d--)!=0)r*=r"
+"\n" "scale=s"
+"\n" "ibase=b"
+"\n" "if(n!=0)return(1/r)"
+"\n" "return(r/1)"
+"\n" "}"
+"\n" "define l(x){"
+"\n" "auto b,s,r,p,a,q,i,v"
+"\n" "b=ibase"
+"\n" "ibase=A"
+"\n" "if(x<=0){"
+"\n" "r=(1-10^scale)/1"
+"\n" "ibase=b"
+"\n" "return(r)"
+"\n" "}"
+"\n" "s=scale"
+"\n" "scale+=6"
+"\n" "p=2"
+"\n" "while(x>=2){"
+"\n" "p*=2"
+"\n" "x=sqrt(x)"
+"\n" "}"
+"\n" "while(x<=0.5){"
+"\n" "p*=2"
+"\n" "x=sqrt(x)"
+"\n" "}"
+"\n" "r=a=(x-1)/(x+1)"
+"\n" "q=a*a"
+"\n" "v=1"
+"\n" "for(i=3;v!=0;i+=2){"
+"\n" "a*=q"
+"\n" "v=a/i"
+"\n" "r+=v"
+"\n" "}"
+"\n" "r*=p"
+"\n" "scale=s"
+"\n" "ibase=b"
+"\n" "return(r/1)"
+"\n" "}"
+"\n" "define s(x){"
+"\n" "auto b,s,r,n,a,q,i"
+"\n" "b=ibase"
+"\n" "ibase=A"
+"\n" "s=scale"
+"\n" "scale=1.1*s+2"
+"\n" "a=a(1)"
+"\n" "if(x<0){"
+"\n" "n=1"
+"\n" "x=-x"
+"\n" "}"
+"\n" "scale=0"
+"\n" "q=(x/a+2)/4"
+"\n" "x=x-4*q*a"
+"\n" "if(q%2!=0)x=-x"
+"\n" "scale=s+2"
+"\n" "r=a=x"
+"\n" "q=-x*x"
+"\n" "for(i=3;a!=0;i+=2){"
+"\n" "a*=q/(i*(i-1))"
+"\n" "r+=a"
+"\n" "}"
+"\n" "scale=s"
+"\n" "ibase=b"
+"\n" "if(n!=0)return(-r/1)"
+"\n" "return(r/1)"
+"\n" "}"
+"\n" "define c(x){"
+"\n" "auto b,s"
+"\n" "b=ibase"
+"\n" "ibase=A"
+"\n" "s=scale"
+"\n" "scale*=1.2"
+"\n" "x=s(2*a(1)+x)"
+"\n" "scale=s"
+"\n" "ibase=b"
+"\n" "return(x/1)"
+"\n" "}"
+"\n" "define a(x){"
+"\n" "auto b,s,r,n,a,m,t,f,i,u"
+"\n" "b=ibase"
+"\n" "ibase=A"
+"\n" "n=1"
+"\n" "if(x<0){"
+"\n" "n=-1"
+"\n" "x=-x"
+"\n" "}"
+"\n" "if(x==1){"
+"\n" "if(scale<65){"
+"\n" "return(.7853981633974483096156608458198757210492923498437764552437361480/n)"
+"\n" "}"
+"\n" "}"
+"\n" "if(x==.2){"
+"\n" "if(scale<65){"
+"\n" "return(.1973955598498807583700497651947902934475851037878521015176889402/n)"
+"\n" "}"
+"\n" "}"
+"\n" "s=scale"
+"\n" "if(x>.2){"
+"\n" "scale+=5"
+"\n" "a=a(.2)"
+"\n" "}"
+"\n" "scale=s+3"
+"\n" "while(x>.2){"
+"\n" "m+=1"
+"\n" "x=(x-.2)/(1+.2*x)"
+"\n" "}"
+"\n" "r=u=x"
+"\n" "f=-x*x"
+"\n" "t=1"
+"\n" "for(i=3;t!=0;i+=2){"
+"\n" "u*=f"
+"\n" "t=u/i"
+"\n" "r+=t"
+"\n" "}"
+"\n" "scale=s"
+"\n" "ibase=b"
+"\n" "return((m*a+r)/n)"
+"\n" "}"
+"\n" "define j(n,x){"
+"\n" "auto b,s,o,a,i,v,f"
+"\n" "b=ibase"
+"\n" "ibase=A"
+"\n" "s=scale"
+"\n" "scale=0"
+"\n" "n/=1"
+"\n" "if(n<0){"
+"\n" "n=-n"
+"\n" "if(n%2==1)o=1"
+"\n" "}"
+"\n" "a=1"
+"\n" "for(i=2;i<=n;++i)a*=i"
+"\n" "scale=1.5*s"
+"\n" "a=(x^n)/2^n/a"
+"\n" "r=v=1"
+"\n" "f=-x*x/4"
+"\n" "scale=scale+length(a)-scale(a)"
+"\n" "for(i=1;v!=0;++i){"
+"\n" "v=v*f/i/(n+i)"
+"\n" "r+=v"
+"\n" "}"
+"\n" "scale=s"
+"\n" "ibase=b"
+"\n" "if(o!=0)a=-a"
+"\n" "return(a*r/1)"
+"\n" "}"
};
#endif // ENABLE_BC