Branch: Tag:

2003-01-27

2003-01-27 10:12:40 by Mirar (Pontus Hagland) <pike@sort.mirar.org>

(large INT_TYPE saga) lsh, rsh and pow fixed"

Rev: src/modules/Gmp/mpz_glue.c:1.122

2:   || 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: mpz_glue.c,v 1.121 2003/01/27 10:01:20 mirar Exp $ + || $Id: mpz_glue.c,v 1.122 2003/01/27 10:12:40 mirar Exp $   */      #include "global.h" - RCSID("$Id: mpz_glue.c,v 1.121 2003/01/27 10:01:20 mirar Exp $"); + RCSID("$Id: mpz_glue.c,v 1.122 2003/01/27 10:12:40 mirar Exp $");   #include "gmp_machine.h"   #include "module.h"   
1343:    if(sp[-1].type == T_INT) {    if(sp[-1].u.integer < 0)    Pike_error("Gmp.mpz->lsh on negative number.\n"); + #if SIZEOF_INT_TYPE > SIZEOF_LONG + /* unsigned long int is the type of the argument to mpz_mul_2exp */ +  if (sp[-1].u.integer != (unsigned long int)sp[-1].u.integer) +  if(mpz_cmp_si(THIS, -1)<0 || mpz_cmp_si(THIS, 1)>0) +  Pike_error("Gmp.mpz->lsh: shift count too large.\n"); + #endif    res = fast_clone_object(THIS_PROGRAM, 0);    mpz_mul_2exp(OBTOMPZ(res), THIS, sp[-1].u.integer);    } else {
1376:    ref_push_type_value(int_type_string);    stack_swap();    f_cast(); -  if(sp[-1].type == T_INT) { +  if(sp[-1].type == T_INT) +  {    if (sp[-1].u.integer < 0)    Pike_error("Gmp.mpz->rsh: Shift count must be positive.\n"); -  + #if SIZEOF_INT_TYPE > SIZEOF_LONG + /* unsigned long int is the type of the argument to mpz_mul_2exp */ +  if (sp[-1].u.integer != (unsigned long int)sp[-1].u.integer) +  {    res = fast_clone_object(THIS_PROGRAM, 0); -  +  mpz_set_si(OBTOMPZ(res), mpz_sgn(THIS)<0? -1:0); +  } +  else + #endif +  { +  res = fast_clone_object(THIS_PROGRAM, 0);    mpz_fdiv_q_2exp(OBTOMPZ(res), THIS, sp[-1].u.integer); -  } else { +  } +  } +  else +  {    INT32 i;    MP_INT *mi = get_mpz(sp-1,1);    if(mpz_sgn(mi)<0)
1469:    if (sp[-1].u.integer < 0)    Pike_error("Gmp.mpz->pow: Negative exponent.\n");    res = fast_clone_object(THIS_PROGRAM, 0); - #ifdef BIG_PIKE_INT + #if SIZEOF_INT_TYPE > SIZEOF_LONG   /* unsigned long int is the type of the argument to mpz_pow_ui */    if (sp[-1].u.integer != (unsigned long int)sp[-1].u.integer)    if(mpz_cmp_si(THIS, -1)<0 || mpz_cmp_si(THIS, 1)>0)