Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.459.mcz==================== Summary ====================
Name: Kernel-nice.459
Author: nice
Time: 12 June 2010, 12:48:39.803 am
UUID: ab072b6c-709f-8748-ab49-d5f71ca3fc92
Ancestors: Kernel-dtl.458
Avoid an overflow when asking for LargeInteger>>#log
Same for fractions of LargeInteger.
This completes the work engaged for #ln and #log:
Note 1: the code is duplicating #ln, but Idid not find any elegant way to avoid this duplication.
Note 2: concerning accuracy, LargeInteger>>#log and#ln might be several ulp off (up to 3, maybe more).
=============== Diff against Kernel-dtl.458 ===============
Item was added:
+ ----- Method: Integer>>log (in category 'mathematical functions') -----
+ log
+ "This function is defined because super log might overflow."
+ | res h |
+ self <= 0 ifTrue: [self error: 'log is only defined for x > 0'].
+ res := super log.
+ res isFinite ifTrue: [^res].
+ h := self highBit.
+ ^2 log * h + (self / (1 << h)) asFloat log!
Item was added:
+ ----- Method: Fraction>>log (in category 'mathematical functions') -----
+ log
+ "This function is defined because super log might overflow.
+ Note that < 1 is tested before converting to float in order to avoid precision loss due to gradual underflow."
+ | res int |
+ self < 1 ifTrue: [^self reciprocal log negated].
+ self <= 0 ifTrue: [self error: 'log is only defined for x > 0'].
+ res := super log.
+ res isFinite ifTrue: [^res].
+ int := self integerPart.
+ ^int log + (self / int) log!