Karim Belabas on Fri, 19 Oct 2012 18:49:22 +0200


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

Re: Word length and number of bits in an integer


* Dirk Laurie [2012-10-19 17:58]:
> 2. Can I rely on the words making up x to be 32-bit?

No :-)

>     If not, how do I find out the word length from inside GP?

Here's one way:

  long_is_64bit() = #(1<<32) == 1

(18:46) gp > \v
           GP/PARI CALCULATOR Version 2.6.0 (development git-93661ca)
          amd64 running linux (x86-64/GMP-5.0.5 kernel) 64-bit version
           compiled: Oct 19 2012, gcc version 4.7.1 (Debian 4.7.1-7) 
                 (readline v6.2 enabled, extended help enabled)
(18:46) gp > long_is_64bit()
%1 = 1


(18:46) gp > \v
           GP/PARI CALCULATOR Version 2.6.0 (development git-5e5a55c)
                i686 running linux (ix86 kernel) 32-bit version
           compiled: Oct 15 2012, gcc version 4.4.5 (Debian 4.4.5-8) 
                 (readline v5.2 enabled, extended help enabled)
(18:47) gp >  long_is_64bit()
%1 = 0

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-bordeaux1.fr/~belabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux1.fr/  [PARI/GP]
`