| Karim Belabas on Mon, 30 Jan 2017 19:08:41 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: Number of 32-bit words in an integer |
* Charles Greathouse [2017-01-30 18:41]:
> Is there a nicer way to compute the number of 32-bit words in a given
> integer than what I'm doing now?
>
> #ifdef LONG_IS_64BIT
> long words = (lgefint(n) - 2) << 1;
> if ((ulong)*int_MSW(n) <= 0xFFFFFFFF)
> words--;
> #else
> long words = lgefint(n) - 2;
> #endif
(expi(n) + 31) >> 5
? (But your version will be faster :-)
Cheers,
K.B.
--
Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17
Universite de Bordeaux Fax: (+33) (0)5 40 00 21 23
351, cours de la Liberation http://www.math.u-bordeaux.fr/~kbelabas/
F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP]
`