[squeak-dev] The Inbox: Kernel-ct.1412.mcz

Levente Uzonyi leves at caesar.elte.hu
Fri Sep 10 01:24:13 UTC 2021


Hi Christoph,

On Tue, 7 Sep 2021, commits at source.squeak.org wrote:

> A new version of Kernel was added to project The Inbox:
> http://source.squeak.org/inbox/Kernel-ct.1412.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-ct.1412
> Author: ct
> Time: 7 September 2021, 11:54:32.77151 pm
> UUID: ca064a0e-13a5-f64f-ac9e-91ae045569a7
> Ancestors: Kernel-eem.1408
>
> Adds non-performant but existing implementation of #isPowerOfTwo on Number. Now 16s isPowerOfTwo works as expected, too. Complements Kernel-nice.1377.
>
> =============== Diff against Kernel-eem.1408 ===============
>
> Item was added:
> + ----- Method: Number>>isPowerOfTwo (in category 'testing') -----
> + isPowerOfTwo
> + 
> + 	^ self strictlyPositive and: [(self log2 \\ 1) isZero]!

It's possible to create a Fraction for which that expression returns true. 
For example (1 << 54 - 1) / (1 << 53).
However, the method should return false for all Fractions due to 
normalization.
I pushed a simpler and probably faster solution based on inheritance to 
the Inbox. See Kernel-ul.1410.


Levente


More information about the Squeak-dev mailing list