Karim Belabas on Fri, 28 May 2010 19:28:40 +0200


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

Re: integer representation in pari


* Bill Allombert [2010-05-28 18:26]:
> On Fri, May 28, 2010 at 11:13:11AM -0400, Sam Steingold wrote:
> > Hi,
> > 
> > On 5/27/10, Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr> wrote:
> > >
> > >  You can also check whether the C macro PARI_KERNEL_GMP is defined,
> > >  but usually it is better to use int_W() to acces the mantissa.
> > 
> > thanks!
> > can I also use int_W to access the mantissa of a t_REAL?
> > (it never explicitly says that, but ...)
> 
> No you cannot. t_REAL mantissa is always in HIGH bytes first,
> so this would not work with the GMP kernel. Note that
> t_REAL mantissa is normalized (i.e. first bit is one).

All this may change (in fact, it *will* change : it is very annoying to
have different internal representations for t_INTs and t_REALs).

In general, direct access to an object's internal representation is
strongly discouraged.

In the 2.4.* branch (2.5-stable-to-be), you can use trunc2nr() or
trun2nr_lg() to recover any part of the matissa as a t_INT.

Btw, why do you want to access words of a t_REAL mantissa in the first place ?

Cheers,

    K.B.
--
Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux.fr/~belabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux.fr/  [PARI/GP]
`