Branch: Tag:

2003-03-25

2003-03-25 19:07:34 by Martin Stjernholm <mast@lysator.liu.se>

Fixed stack error in int64_from_bignum for negative integers. Use negation
instead of complement since gmp implements negation faster.

Rev: src/bignum.c:1.23

169:          if(neg) { -  apply_low(sp[-1].u.object,FIND_LFUN(sp[-1].u.object->prog,LFUN_COMPL),0); +  apply_low(sp[-1].u.object,FIND_LFUN(sp[-1].u.object->prog,LFUN_SUBTRACT),0);    stack_pop_n_elems_keep_top(1);    }    }
189:    neg = (--sp)->u.integer;       if(neg) -  apply_low(bignum, FIND_LFUN(bignum->prog, LFUN_COMPL), 0); +  apply_low(bignum, FIND_LFUN(bignum->prog, LFUN_SUBTRACT), 0); +  else +  ref_push_object(bignum);       rshfun = FIND_LFUN(bignum->prog, LFUN_RSH);    andfun = FIND_LFUN(bignum->prog, LFUN_AND);    -  ref_push_object(bignum); -  +     for(pos = 0; sp[-1].type != T_INT; )    {    push_int(BIGNUM_INT64_MASK);
207:       push_int(BIGNUM_INT64_SHIFT);    apply_low(sp[-2].u.object, rshfun, 1); -  stack_swap(); -  pop_stack(); +  stack_pop_n_elems_keep_top(1);    }       *i |= (INT64)(--sp)->u.integer << (INT64)pos;       if(neg) -  *i = ~*i; +  *i = -*i;       return 1; /* We may someday return 0 if the conversion fails. */   }   #endif /* INT64 */      #endif /* AUTO_BIGNUM */