[Pkg] The Trunk: Kernel-nice.1258.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Aug 20 08:03:03 UTC 2019

Nicolas Cellier uploaded a new version of Kernel to project The Trunk:

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

Name: Kernel-nice.1258
Author: nice
Time: 20 August 2019, 10:02:55.377539 am
UUID: a05ee2dc-141d-f54b-8c76-9d4dc6b3c7ee
Ancestors: Kernel-mt.1257

Minor tweak: if log2 is exact, then can log: 4, 8, 16, 32 too

=============== Diff against Kernel-mt.1257 ===============

Item was changed:
  ----- Method: Fraction>>log2 (in category 'mathematical functions') -----
+ 	"This function is defined because super log2 might overflow."
- 	"This function is defined because super log might overflow."
  	| res |
  	self <= 0 ifTrue: [DomainError signal: 'log2 is only defined for x > 0'].
  	"Test self < 1 before converting to float in order to avoid precision loss due to gradual underflow."
  	numerator < denominator ifTrue: [^self reciprocal log2 negated].
  	res := super log2.
  	res isFinite ifTrue: [^res].
  	^numerator log2 - denominator log2!

Item was changed:
  ----- Method: Number>>log: (in category 'mathematical functions') -----
  log: aNumber 
  	"Answer the log base aNumber of the receiver."
  	aNumber = 2 ifTrue: [^self log2].
+ 	aNumber isPowerOfTwo ifTrue: [^self log2 / aNumber log2].
  	^self ln / aNumber ln!

More information about the Packages mailing list