diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2005-04-02 18:05:05 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2005-04-02 18:05:05 +0000 |
commit | 0dfbe0d4827533363f3ab777a2d77fa123c297fc (patch) | |
tree | 69b0dca1d37e7058a62298caad948ee75f9eeb1d /usr.bin/dc/bcode.c | |
parent | b7132bf62cb8a0640050fc59ab7bef53163dd439 (diff) |
- Fix raise for negative exponents (noted by naddy@)
- Fix wrong scale for mantissa < 1.
Diffstat (limited to 'usr.bin/dc/bcode.c')
-rw-r--r-- | usr.bin/dc/bcode.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c index d863ef131a7..bdf6b6273fb 100644 --- a/usr.bin/dc/bcode.c +++ b/usr.bin/dc/bcode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcode.c,v 1.28 2005/03/28 17:39:20 deraadt Exp $ */ +/* $OpenBSD: bcode.c,v 1.29 2005/04/02 18:05:04 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net> @@ -17,7 +17,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: bcode.c,v 1.28 2005/03/28 17:39:20 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: bcode.c,v 1.29 2005/04/02 18:05:04 otto Exp $"; #endif /* not lint */ #include <ssl/ssl.h> @@ -1190,7 +1190,7 @@ bexp(void) negate(p); scale = bmachine.scale; } else { - /* Posix bc says min(a.scale *b, max(a.scale, scale) */ + /* Posix bc says min(a.scale * b, max(a.scale, scale) */ u_long b; u_int m; @@ -1231,12 +1231,13 @@ bexp(void) BN_one(one); ctx = BN_CTX_new(); bn_checkp(ctx); - r->scale = scale; - scale_number(one, r->scale); + scale_number(one, r->scale + scale); + normalize(r, scale); bn_check(BN_div(r->number, NULL, one, r->number, ctx)); BN_free(one); BN_CTX_free(ctx); - } + } else + normalize(r, scale); } push_number(r); free_number(a); |