summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-05 07:45:32 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-05 07:45:32 +0000
commit57cf603496ac64d705e05721f80c40754db4bad5 (patch)
tree0217a1d86ee79d97945c037788835eeadd849007
parentadae2a7361796aed02bde1f41e849e3abb75e6ef (diff)
downloadruby-57cf603496ac64d705e05721f80c40754db4bad5.tar.gz
* eval.c (top_include): include in the wrapped load is done for
the wrapper, not for a singleton class for wrapped main. [ruby-dev:23305] * bignum.c (rb_big_eq): use temporary double variable to save the result (internal float register may be bigger than 64 bits, for example, 80 bits on x86). [ruby-dev:23311] * eval.c (block_pass): should generate unique identifier of the pushing block. [ruby-talk:96363] * ext/socket/socket.c (make_hostent): fix memory leak, based on the patch from HORIKAWA Hisashi <vzw00011@nifty.ne.jp>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/unlabeled-1.39.2@6092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/bigdecimal/bigdecimal.c33
1 files changed, 8 insertions, 25 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 6a9940d335..fa37766346 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2213,8 +2213,7 @@ VpAddAbs(Real *a, Real *b, Real *c)
while(b_pos + word_shift > a_pos) {
--c_pos;
if(b_pos > 0) {
- --b_pos;
- c->frac[c_pos] = b->frac[b_pos];
+ c->frac[c_pos] = b->frac[--b_pos];
} else {
--word_shift;
c->frac[c_pos] = 0;
@@ -2225,19 +2224,14 @@ VpAddAbs(Real *a, Real *b, Real *c)
/* corresponding digits to be added. */
bv = b_pos + word_shift;
while(a_pos > bv) {
- --c_pos;
- --a_pos;
- c->frac[c_pos] = a->frac[a_pos];
+ c->frac[--c_pos] = a->frac[--a_pos];
}
carry = 0; /* set first carry be zero */
/* Now perform addition until every digits of b will be */
/* exhausted. */
while(b_pos > 0) {
- --a_pos;
- --b_pos;
- --c_pos;
- c->frac[c_pos] = a->frac[a_pos] + b->frac[b_pos] + carry;
+ c->frac[--c_pos] = a->frac[--a_pos] + b->frac[--b_pos] + carry;
if(c->frac[c_pos] >= BASE) {
c->frac[c_pos] -= BASE;
carry = 1;
@@ -2249,9 +2243,7 @@ VpAddAbs(Real *a, Real *b, Real *c)
/* Just assign the first few digits of a with considering */
/* the carry obtained so far because b has been exhausted. */
while(a_pos > 0) {
- --a_pos;
- --c_pos;
- c->frac[c_pos] = a->frac[a_pos] + carry;
+ c->frac[--c_pos] = a->frac[--a_pos] + carry;
if(c->frac[c_pos] >= BASE) {
c->frac[c_pos] -= BASE;
carry = 1;
@@ -2320,14 +2312,10 @@ VpSubAbs(Real *a, Real *b, Real *c)
/* corresponding digits to be subtracted. */
if(b_pos + word_shift > a_pos) {
borrow = 1;
- --c_pos;
- --b_pos;
- c->frac[c_pos] = BASE - b->frac[b_pos];
while(b_pos + word_shift > a_pos) {
--c_pos;
if(b_pos > 0) {
- --b_pos;
- c->frac[c_pos] = BASE - b->frac[b_pos] - borrow;
+ c->frac[c_pos] = BASE - b->frac[--b_pos] - borrow;
} else {
--word_shift;
c->frac[c_pos] = BASE - borrow;
@@ -2339,18 +2327,14 @@ VpSubAbs(Real *a, Real *b, Real *c)
bv = b_pos + word_shift;
while(a_pos > bv) {
- --c_pos;
- --a_pos;
- c->frac[c_pos] = a->frac[a_pos];
+ c->frac[--c_pos] = a->frac[--a_pos];
}
/* Now perform subtraction until every digits of b will be */
/* exhausted. */
while(b_pos > 0) {
- --a_pos;
- --b_pos;
--c_pos;
- if(a->frac[a_pos] < b->frac[b_pos] + borrow) {
+ if(a->frac[--a_pos] < b->frac[--b_pos] + borrow) {
c->frac[c_pos] = BASE + a->frac[a_pos] - b->frac[b_pos] - borrow;
borrow = 1;
} else {
@@ -2363,8 +2347,7 @@ VpSubAbs(Real *a, Real *b, Real *c)
/* the borrow obtained so far because b has been exhausted. */
while(a_pos > 0) {
--c_pos;
- --a_pos;
- if(a->frac[a_pos] < borrow) {
+ if(a->frac[--a_pos] < borrow) {
c->frac[c_pos] = BASE + a->frac[a_pos] - borrow;
borrow = 1;
} else {