[Cuis-dev] Bug in Integer>>#raisedTo:modulo:
Juan Vuletich
juan at cuis.st
Tue Jun 6 07:59:12 PDT 2023
Hi Folks,
Thanks Luciano and Nicolas for finding the problem and the solution.
I just pushed an update to GitHub. Just removed senders _and_
implementors of #\\\. That method doesn't carry its own weight. I also
wrote a test with Luciano's example.
Cheers,
On 6/5/2023 2:17 PM, Luciano Notarfrancesco via Cuis-dev wrote:
> Makes sense, thank you!
>
> On Mon, 5 Jun 2023 at 19:11 Nicolas Cellier
> <nicolas.cellier.aka.nice at gmail.com
> <mailto:nicolas.cellier.aka.nice at gmail.com>> wrote:
>
> I replaced ALL sends, not just this one, because it's putting too
> much responsibility for senders for a very weak gain
>
> Le lun. 5 juin 2023 à 19:09, Luciano Notarfrancesco
> <luchiano at gmail.com <mailto:luchiano at gmail.com>> a écrit :
>
> Ah, good to know, you replaced all calls to \\\ with \\ in all
> methods or only this one? We should do the same in Cuis.
> Still, the randomness mystery remains…
>
> On Mon, 5 Jun 2023 at 19:04 Nicolas Cellier via Cuis-dev
> <cuis-dev at lists.cuis.st <mailto:cuis-dev at lists.cuis.st>> wrote:
>
> Ah OK... I expunged the sends of \\\ operator from Squeak.
> This is exactly like \\ but omits normalization of
> LargeInteger result...
> Below is the comment that i let in \\\ definition:
>
>
> "A modulo method former used in DSA."
>
> "Notes: this method used to be a faster than \\ for
> LargeIntegers, but this advantage is fainting:
> - it always was slower for SmallInteger because of the
> indirection below
> - a new LargeInteger primitive makes \\ faster up to 64
> bits operands
> - even above 64 bits, its advantage has become marginal
> thanks to revised \\ primitive fallback code
> Moreover, \\\ behaviour is questionable for these reasons:
> - for a negative receiver xor argument, it behaves like
> rem: for LargeInteger and \\ for SmallInteger
> - it may answer a not normalized LargeInteger (with
> leading null digits) which breaks some invariants
> For example, check (SmallInteger maxVal + 1 \\\ 8) isZero.
> So beware if you ever think using this method."
>
>
> Le lun. 5 juin 2023 à 18:56, Luciano Notarfrancesco via
> Cuis-dev <cuis-dev at lists.cuis.st
> <mailto:cuis-dev at lists.cuis.st>> a écrit :
>
> Doing
> pow := pow * pow \\ m
> instead of
> pow := pow * pow \\\ m
> at the beginning of the loop in
> Integer>>#slidingLeftRightRaisedTo:modulo: seems to
> fix it. But still I’m not sure why it is random
> otherwise, and I’m not sure that this really fixes the
> problem.
>
>
> On Mon, 5 Jun 2023 at 18:42 Luciano Notarfrancesco
> <luchiano at gmail.com <mailto:luchiano at gmail.com>> wrote:
>
> The following:
> 5445648384 raisedTo: 3 modulo: 1 << 34
> Returns 0, which is right. But
> 5445648384 raisedTo: 4 modulo: 1 << 34
> Returns different numbers every time I call it (it
> should return 0).
> It’s very weird… I don’t see where the randomness
> is coming from, perhaps from LargeIntegerPlugin?
>
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st <mailto:Cuis-dev at lists.cuis.st>
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st <mailto:Cuis-dev at lists.cuis.st>
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>
--
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230606/7106d153/attachment.htm>
More information about the Cuis-dev
mailing list