aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-14 09:53:50 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-14 09:53:50 +0100
commit203210e2535e7543e415b052e1d7182f3ca32959 (patch)
tree1752716151c1c391f873fbd636dcc6984d9f45ec
parent3ac0c21a1fe902c7bebadc0fc454ee047e13c58f (diff)
downloadbusybox-w32-203210e2535e7543e415b052e1d7182f3ca32959.tar.gz
busybox-w32-203210e2535e7543e415b052e1d7182f3ca32959.tar.bz2
busybox-w32-203210e2535e7543e415b052e1d7182f3ca32959.zip
bc: shrink internal library more
function old new delta bc_lib 1618 1609 -9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 0a2da6cf8..8befc8e3f 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -7143,6 +7143,12 @@ static const char bc_lib[] ALIGN1 = {
7143 "scale=20" 7143 "scale=20"
7144"\n" "define e(x){" 7144"\n" "define e(x){"
7145"\n" "auto b,s,n,r,d,i,p,f,v" 7145"\n" "auto b,s,n,r,d,i,p,f,v"
7146////////////////"if(x<0)return(1/e(-x))" // and drop 'n' and x<0 logic below
7147//^^^^^^^^^^^^^^^^ this would work, and is even more precise than GNU bc:
7148//e(-.998896): GNU:.36828580434569428695
7149// above code:.36828580434569428696
7150// actual value:.3682858043456942869594...
7151// but for now let's be "GNU compatible"
7146"\n" "b=ibase" 7152"\n" "b=ibase"
7147"\n" "ibase=A" 7153"\n" "ibase=A"
7148"\n" "if(x<0){" 7154"\n" "if(x<0){"
@@ -7219,7 +7225,7 @@ static const char bc_lib[] ALIGN1 = {
7219"\n" "}" 7225"\n" "}"
7220"\n" "scale=0" 7226"\n" "scale=0"
7221"\n" "q=(x/a+2)/4" 7227"\n" "q=(x/a+2)/4"
7222"\n" "x=x-4*q*a" 7228"\n" "x-=4*q*a"
7223"\n" "if(q%2)x=-x" 7229"\n" "if(q%2)x=-x"
7224"\n" "scale=s+2" 7230"\n" "scale=s+2"
7225"\n" "r=a=x" 7231"\n" "r=a=x"
@@ -7288,7 +7294,7 @@ static const char bc_lib[] ALIGN1 = {
7288"\n" "n/=1" 7294"\n" "n/=1"
7289"\n" "if(n<0){" 7295"\n" "if(n<0){"
7290"\n" "n=-n" 7296"\n" "n=-n"
7291"\n" "if(n%2==1)o=1" 7297"\n" "o=n%2"
7292"\n" "}" 7298"\n" "}"
7293"\n" "a=1" 7299"\n" "a=1"
7294"\n" "for(i=2;i<=n;++i)a*=i" 7300"\n" "for(i=2;i<=n;++i)a*=i"