Nicolas Cellier uploaded a new version of Kernel to project The Trunk: http://source.squeak.org/trunk/Kernel-nice.694.mcz
==================== Summary ====================
Name: Kernel-nice.694 Author: nice Time: 3 June 2012, 5:31:52.95 pm UUID: faa4f8ea-259e-47d4-adc7-eeb195787cad Ancestors: Kernel-nice.693
Protect floorLog: 2 for case of exceptional float values (because exponent does not) Change exponent primitive fallback code to avoid a recursion with floorLog2: Note that I created a separate selector #exponentFromBitPattern for handling fallback, because it's easier to test.
=============== Diff against Kernel-nice.693 ===============
Item was changed: ----- Method: Float>>exponent (in category 'truncation and round off') ----- exponent "Primitive. Consider the receiver to be represented as a power of two multiplied by a mantissa (between one and two). Answer with the SmallInteger to whose power two is raised. Optional. See Object documentation whatIsAPrimitive."
- | positive | <primitive: 53> + ^self exponentFromBitPattern! - self >= 1.0 ifTrue: [^self floorLog: 2]. - self > 0.0 - ifTrue: - [positive := (1.0 / self) exponent. - self = (1.0 / (1.0 timesTwoPower: positive)) - ifTrue: [^positive negated] - ifFalse: [^positive negated - 1]]. - self = 0.0 ifTrue: [^-1]. - ^self negated exponent!
Item was added: + ----- Method: Float>>exponentFromBitPattern (in category 'truncation and round off') ----- + exponentFromBitPattern + "Extract the exponent from the bit pattern. + This is used only when primitive fails" + + | exponent word1 | + self isFinite ifFalse: [^self error: 'cannot take the exponent of non finite Float']. + self = 0.0 ifTrue: [^-1]. + word1 := self basicAt: 1. + exponent := (word1 bitShift: -20) bitAnd: 16r7FF. + ^exponent = 0 + ifTrue: + [| high | + high := (word1 bitAnd: 16rFFFFF) highBit. + high := high = 0 + ifTrue: [(self basicAt: 2) highBit] + ifFalse: [high + 32]. + self class emin - self class precision + high] + ifFalse: + [exponent + self class emin - 1]!
Item was changed: ----- Method: Float>>floorLog: (in category 'mathematical functions') ----- floorLog: radix "Answer the floor of the log base radix of the receiver. The result may be off by one due to rounding errors, except in base 2."
+ (radix = 2 and: [self > 0.0 and: [self isFinite]]) ifTrue: [^self exponent]. - (radix = 2 and: [self > 0.0]) ifTrue: [^self exponent]. ^ (self log: radix) floor !
squeak-dev@lists.squeakfoundation.org