| Aleksandr Lenin on Wed, 28 Mar 2018 13:48:06 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: Random bitstring generation in PARI library |
On 03/27/2018 09:29 PM, Bill Allombert wrote: > On Tue, Mar 27, 2018 at 02:41:46PM +0300, Aleksandr Lenin wrote: >> Hello, >> >> what is the procedure to generate a random k-bit number, where k is >> greater than BITS_IN_LONG? > > In GP, random(2^k) > >> Reading through the manual >> (https://pari.math.u-bordeaux.fr/pub/pari/manuals/2.10.0/libpari.pdf) I >> managed to find only pari_rand, random_bits, random_Fl which return an >> (unsigned) long, and I need a bigger number. The function randomi indeed >> returns a GEN, but in the range 1..p-1, but I need a random bitstring of >> length k. > > In C you can do randomi(int2n(k)) this would return me a number in the range [0,2^k-1], this is not exactly what I need. I would like to be able to generate numbers of k-bit length only. > > Cheers, > Bill. > -- With kind regards, Aleksandr