bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Segmentation fault when computing square root.


From: Erik Backerud
Subject: Segmentation fault when computing square root.
Date: Sat, 26 Jan 2002 21:09:32 +0100 (CET)

Bug  found:

Gmp gives a segmentation fault when trying to extract the square root
of large numbers using the mpz_sqrt() function.
Specifically the number i am trying to extract a root from is:
2*10^20000000

Sample program to demonstrate the bug:

---------- start if sample program small.c ----------
#include <stdio.h>
#include <gmp.h>

int
main(int argc, char *argv[])
{
  mpz_t x, y;

  mpz_init(x);
  mpz_init(y);
  mpz_ui_pow_ui(x, 10, 20000000);
  mpz_mul_ui(x, x, 2);
  fprintf(stderr, "argument ready\n");
  mpz_sqrt(y, x);
  fprintf(stderr, "sqrt ready\n");
  mpz_clear(x);
  mpz_clear(y);
  return 0;
}       /* main */
---------- end if sample program small.c ----------

Machine details:
GMP-4.0
        default installation like this:
        ./configure ; make ; make install

O/S: Slackware Linux, kernel 2.4.15

gcc version: 2.95.3

Pentium-2 CPU, 256Mb RAM.

(Same results observed on a Pentium-3 machine and on a Sparc classic)

Best Regards
Erik Backerud

----------------------------------------------------------------------
Erik Backerud. Room no. 2204; Phone: 222 49 08; email: address@hidden
Dept. of Computer Science, Lund Institute of Technology.  Lund, Sweden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]