[Pkg] The Trunk: Kernel-fbs.698.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Jun 11 20:14:03 UTC 2012


Frank Shearar uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-fbs.698.mcz

==================== Summary ====================

Name: Kernel-fbs.698
Author: fbs
Time: 11 June 2012, 9:12:51.486 pm
UUID: ceb4e4d0-4031-429d-9001-dd4dc44258ac
Ancestors: Kernel-fbs.697, Kernel-nice.694

Remerge Kernel-nice.694:

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-fbs.697 ===============

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
  !



More information about the Packages mailing list