[squeak-dev] Squeak 4.5 error: #isPrime fails with relatively small Mersenne prime

Bert Freudenberg bert at freudenbergs.de
Tue Feb 10 15:37:35 UTC 2015


On 10.02.2015, at 13:39, David T. Lewis <lewis at mail.msen.com> wrote:
> 
> On Tue, Feb 10, 2015 at 02:39:19AM -0700, Lawson English wrote:
>> This bit of code fails at numb := 1024:
>> 
>> error: Cannot truncate this number
>> 
>> numb := 1024.
>> 1 to: numb do: [:n||test| test:=(2 raisedTo: n) -1. (test isPrime) 
>> ifTrue: [Transcript show: n; tab; show: test;cr]]
>> 
>> #isProbablyPrime fails with the same number.
>> 
>> 
>> numb := 1023.
>> works for both.
>> 
> 
> It looks like a problem in random number generation. It is failing in
> LargePositiveInteger>>atRandom which somehow results in the random
> generator producing a value of Float infinity.
> 
> Dave

Yep. Random>>nextInt: does not work for really large ints. Fixed in Kernel-bf.899.

- Bert -



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4115 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20150210/40407f1a/smime.bin


More information about the Squeak-dev mailing list