Jacques Gélinas on Mon, 30 Jan 2017 19:21:28 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Number of 32-bit words in an integer
|
- To: "pari-dev@pari.math.u-bordeaux.fr" <pari-dev@pari.math.u-bordeaux.fr>
- Subject: Re: Number of 32-bit words in an integer
- From: Jacques Gélinas <jacquesg00@hotmail.com>
- Date: Mon, 30 Jan 2017 18:21:18 +0000
- Accept-language: en-US
- Authentication-results: pari.math.u-bordeaux.fr; dkim=none (message not signed) header.d=none;pari.math.u-bordeaux.fr; dmarc=none action=none header.from=hotmail.com;
- Delivery-date: Mon, 30 Jan 2017 19:21:28 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=YgP+v78aebUg6NdELktcxoabWJJaDnbKX7uCmL0XQ7A=; b=jKdesq4d1z/9KY2vAHtE8DdJnPCbkF0WdmGqEHn0zoM5HEgLvJRlurY5dr5ozsk1/7SjdYW1EaZTRH77n7LArFNjB2tFhGfNB1kAZ/dFSjPRVXDcpoNdinsyalrF3JPokqk6NUBa69cUJhzCLF9z7opvdsgN7pyphA4qF8dX9wcFRap3p2hDV0e29CzENjW4p51gen2F+8Bn3FNezYltL9zdyP4GM0I8hjgMD26xWvMoYERLsSIw/qX6yURaMx6/vXyXXEXjrkr8iDIB8NOD7jRp5yDp53Nd7jx/vRhFpZWO3ALUAKSVYXKQ/KLkrmxAxHfa4SJnkx/hIzj1YY85NA==
- In-reply-to: <CAAkfSGL+sJ3G50U_zWvvM84zFMyvqUqUtnT1ej3u0PeNyAqP6g@mail.gmail.com>
- References: <CAAkfSGL+sJ3G50U_zWvvM84zFMyvqUqUtnT1ej3u0PeNyAqP6g@mail.gmail.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
- Thread-index: AQHSeyAf1WRMvwY6LUm/FTZpE48m+KFRT1re
- Thread-topic: Number of 32-bit words in an integer
You first need the number of bits in a word, and this is what I use:
/* PARI/GP floating point [base, words, bits, meps] */
flpari(p=precision(1.)) = {
local( w = #precision(1.,p) );
[2, w, w*=64/#precision(1.,18), 2.>>w];
}
addhelp(flpari,"flpari(p): parameters of p-decimal PARI/GP floating-point arithmetic \
[base, words, bits, machine epsilon]")
Next, #(2^257-1) will give 5 on a 64-bit machine, but 9 on a 32-bit machine
while #(2^256-1) will give 4 on a 64-bit machine, but 8 on a 32-bit machine,
so maybe you can use
words(N=2^256-1) = round( #N / precision(1.,18) )
but there should be a simpler way avoiding the use of floating-point and rounding ?
Jacques Gélinas