diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2012-03-14 07:35:54 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2012-03-14 07:35:54 +0000 |
commit | e0b5d824208b47eaf3d8e82f8121315977c5d1bb (patch) | |
tree | b872264700684f545a19bdcd181f35cc8b5afa92 | |
parent | 3747e8faf370d3345288a31d5c570e25ec4aa6fe (diff) |
repair function when used with different scales; from AIDA Shinra, thanks!
-rw-r--r-- | usr.bin/bc/bc.library | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/usr.bin/bc/bc.library b/usr.bin/bc/bc.library index 83cc1b4ea8f..69f4c115386 100644 --- a/usr.bin/bc/bc.library +++ b/usr.bin/bc/bc.library @@ -1,4 +1,4 @@ -/* $OpenBSD: bc.library,v 1.3 2007/02/03 21:15:06 otto Exp $ */ +/* $OpenBSD: bc.library,v 1.4 2012/03/14 07:35:53 otto Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -45,7 +45,9 @@ define e(x) { r = ibase ibase = A t = scale - scale = t + .434*x + 1 + scale = 0 + if (x > 0) scale = (0.435*x)/1 + scale = scale + t + length(scale + t) + 1 w = 0 if (x < 0) { @@ -94,26 +96,34 @@ define l(x) { t = scale f = 1 - scale = scale + scale(x) - length(x) + 1 - s = scale + if (x < 1) { + s = scale(x) + } else { + s = length(x)-scale(x) + } + scale = 0 + a = (2.31*s)/1 /* estimated integer part of the answer */ + s = t + length(a) + 2 /* estimated length of the answer */ while (x > 2) { - s = s + (length(x) - scale(x))/2 + 1 - if (s > 0) scale = s + scale = 0 + scale = (length(x) + scale(x))/2 + 1 + if (scale < s) scale = s x = sqrt(x) f = f*2 } while (x < .5) { - s = s + (length(x) - scale(x))/2 + 1 - if (s > 0) scale = s + scale = 0 + scale = scale(x)/2 + 1 + if (scale < s) scale = s x = sqrt(x) f = f*2 } - scale = t + length(f) - scale(f) + 1 + scale = 0 + scale = t + length(f) + length((1.05*(t+length(f))/1)) + 1 u = (x - 1)/(x + 1) - - scale = scale + 1.1*length(t) - 1.1*scale(t) s = u*u + scale = t + 2 b = 2*f c = b d = 1 |