[squeak-dev] The Inbox: Kernel-ul.1410.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Sep 10 00:24:55 UTC 2021
Levente Uzonyi uploaded a new version of Kernel to project The Inbox:
http://source.squeak.org/inbox/Kernel-ul.1410.mcz
==================== Summary ====================
Name: Kernel-ul.1410
Author: ul
Time: 10 September 2021, 2:24:41.798614 am
UUID: 471ec32e-c74e-4a21-b5df-431f058878fe
Ancestors: Kernel-ul.1409
- let all Numbers respond to #isPowerOfTwo.
- removed Integer >> #isPowerOfTwo because it was not used: all subclasses implement that method
- speed up Float >> #isPowerOfTwo at the cost of relying on the exact bit representation
=============== Diff against Kernel-ul.1409 ===============
Item was changed:
----- Method: Float>>isPowerOfTwo (in category 'testing') -----
isPowerOfTwo
+ "Return true if the receiver is an integral power of two. Optimized version."
+
+ | firstWord |
+ (self basicAt: 2) = 0 ifFalse: [ ^false ].
+ ((firstWord := self basicAt: 1) bitAnd: 16rFFFFF) = 0 ifFalse: [ ^false ].
+ (firstWord := firstWord bitShift: -20) >= 16r7FF ifTrue: [ ^false. "infinitiy, negative, nan" ].
+ ^firstWord >= 16r3FF!
- "Return true if the receiver is an integral power of two."
- ^self significand = 1.0!
Item was added:
+ ----- Method: Fraction>>isPowerOfTwo (in category 'testing') -----
+ isPowerOfTwo
+ "Return true if the receiver is an integral power of two."
+
+ ^false!
Item was removed:
- ----- Method: Integer>>isPowerOfTwo (in category 'testing') -----
- isPowerOfTwo
- "Return true if the receiver is an integral power of two."
-
- ^self strictlyPositive and: [ (self bitAnd: self - 1) = 0 ]!
Item was added:
+ ----- Method: Number>>isPowerOfTwo (in category 'testing') -----
+ isPowerOfTwo
+ "Return true if the receiver is an integral power of two."
+
+ self subclassResponsibility!
Item was added:
+ ----- Method: ScaledDecimal>>isPowerOfTwo (in category 'testing') -----
+ isPowerOfTwo
+ "Return true if the receiver is an integral power of two."
+
+ ^fraction isPowerOfTwo!
More information about the Squeak-dev
mailing list
|