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

Problem with porting PARI/GP to arm: double (float) format


I have made a test build of my package pari on debussy.debian.org and
while the package compile O.K. the test suit find two (serious) bugs.
The first one is linked to the way 'double' (floating point) are stored in

the relevant code look like

#  define INDEX0 1
#  define INDEX1 0
#  define INDEX0 0
#  define INDEX1 1
   error... unknown machine

dbltor(double x)
  GEN z;
  long e;
  union { double f; ulong i[2]; } fi;
  const int mant_len = 52;  /* mantissa bits (excl. hidden bit) */
  const int exp_mid = 0x3ff;/* exponent bias */
  const int shift = mant_len-32;
  const int expo_len = 11; /* number of bits of exponent */

  if (x==0) { z=cgetr(3); z[1]=evalexpo(-308); z[2]=0; return z; }
  fi.f = x; z=cgetr(4);
    const ulong a = fi.i[INDEX0];
    const ulong b = fi.i[INDEX1];
    e = evalexpo(((a & (HIGHBIT-1)) >> shift) - exp_mid);
    z[1] = e | evalsigne(x<0? -1: 1);
    z[3] = b << expo_len;
    z[2] = HIGHBIT | b >> (BITS_IN_LONG-expo_len) | (a << expo_len);
  return z;
GEN is the pari generic type.

Upstream author know about this problem and believe that the solution is
that correct #define for arm are

#  define INDEX0 1
#  define INDEX1 0
(so as if it was big-endian).

I test it and it works.

Can someone explain me what happen, so that I work out a good patch ?

The second problem need more investigation.
(note: the relevant files (with the change are on my account on debussy.
this was extract from ~/pari-2.1.1/src/kernel/none/mp.c)

(Please CC me, I read mailing lists from the archive)

Reply to: