pike.git / src / bignum.c

version» Context lines:

pike.git/src/bignum.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: bignum.c,v 1.29 2003/02/21 17:42:21 grubba Exp $ + || $Id: bignum.c,v 1.30 2003/03/25 19:07:48 mast Exp $   */      #include "global.h"      #ifdef AUTO_BIGNUM      #include "interpret.h"   #include "program.h"   #include "object.h"   #include "svalue.h"
pike.git/src/bignum.c:147: Inside #if defined(INT64) and #if PIKE_BYTEORDER == 1234
   push_string( make_shared_binary_string( digits, 8 ) );    }   #else    push_string( make_shared_binary_string( (char *)&i, 8 ) );   #endif    push_int( 256 );    apply_svalue(&auto_bignum_program, 2);          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);    }    }   }      /* This routines can be optimized quite drastically. */   #define BIGNUM_INT64_MASK 0xffffff   #define BIGNUM_INT64_SHIFT 24   PMOD_EXPORT int int64_from_bignum(INT64 *i, struct object *bignum)   {
pike.git/src/bignum.c:169:       *i = 0;       push_int(0);    apply_low(bignum, FIND_LFUN(bignum->prog, LFUN_LT), 1);    if(sp[-1].type != T_INT)    Pike_error("Result from Gmp.bignum->`< not an integer.\n");    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);    apply_low(sp[-2].u.object, andfun, 1);    if(sp[-1].type != T_INT)    Pike_error("Result from Gmp.bignum->`& not an integer.\n");    *i |= (INT64)(--sp)->u.integer << (INT64)pos;    pos += BIGNUM_INT64_SHIFT;       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 */