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

Eliot Miranda eliot.miranda at gmail.com
Wed Sep 8 23:38:40 UTC 2021


Hi Christoph,

On Tue, Sep 7, 2021 at 2:54 PM <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]!
>

If you care, fractionPart is about 6 times faster than \\ 1:

[4.0 fractionPart] bench '70,000,000 per second. 14.3 nanoseconds per run.
0 % GC time.'
[4.0 \\ 1] bench '10,300,000 per second. 97.2 nanoseconds per run. 0 % GC
time.'

log2 always answers a float, and all scalar numbers respond to fractionPart.

_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210908/b202e312/attachment.html>


More information about the Squeak-dev mailing list