Branch: Tag:

2003-01-27

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

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

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

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.122 2003/01/27 10:12:40 mirar Exp $ + || $Id: mpz_glue.c,v 1.123 2003/01/27 10:44:54 mirar Exp $   */      #include "global.h" - RCSID("$Id: mpz_glue.c,v 1.122 2003/01/27 10:12:40 mirar Exp $"); + RCSID("$Id: mpz_glue.c,v 1.123 2003/01/27 10:44:54 mirar Exp $");   #include "gmp_machine.h"   #include "module.h"   
1347: Inside #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"); +  goto too_large;   #endif    res = fast_clone_object(THIS_PROGRAM, 0);    mpz_mul_2exp(OBTOMPZ(res), THIS, sp[-1].u.integer);
1357:    if(mpz_sgn(mi)<0)    Pike_error("Gmp.mpz->lsh on negative number.\n");    i=mpz_get_si(mi); -  if(mpz_cmp_si(mi, i)) { +  if(mpz_cmp_si(mi, i)) +  { + too_large: +  push_text("%O\n"); +  stack_swap(); +  f_sprintf(2); +     if(mpz_sgn(THIS))    Pike_error("Gmp.mpz->lsh: shift count too large.\n");    else {
1427:    if(mpz_sgn(THIS) < 0)    Pike_error("Gmp.mpz->``<< on negative number.\n");    i=mpz_get_si(THIS); +     if(mpz_cmp_si(THIS, i)) {    if(mpz_sgn(OBTOMPZ(sp[-1].u.object)))    Pike_error("Gmp.mpz->``<<: shift count too large.\n");
1488:    if (sp[-1].type == T_INT) {    if (sp[-1].u.integer < 0)    Pike_error("Gmp.mpz->pow: Negative exponent.\n"); -  res = fast_clone_object(THIS_PROGRAM, 0); +    #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) -  Pike_error("Gmp.mpz->pow: Exponent too large.\n"); +  goto too_large;   #endif -  +  res = fast_clone_object(THIS_PROGRAM, 0);    mpz_pow_ui(OBTOMPZ(res), THIS, sp[-1].u.integer);    } else {    INT32 i;
1503:    Pike_error("Gmp.mpz->pow: Negative exponent.\n");    i=mpz_get_si(mi);    if(mpz_cmp_si(mi, i)) +  { + too_large:    if(mpz_cmp_si(THIS, -1)<0 || mpz_cmp_si(THIS, 1)>0)    Pike_error("Gmp.mpz->pow: Exponent too large.\n");    else {
1521:    break;    }    } +  }    else {    res = fast_clone_object(THIS_PROGRAM, 0);    mpz_pow_ui(OBTOMPZ(res), THIS, i);