[squeakdev] The Trunk: Kernelnice.459.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Jun 11 22:49:20 UTC 2010
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernelnice.459.mcz
==================== Summary ====================
Name: Kernelnice.459
Author: nice
Time: 12 June 2010, 12:48:39.803 am
UUID: ab072b6c709f8748ab49d5f71ca3fc92
Ancestors: Kerneldtl.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 Kerneldtl.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!
More information about the Squeakdev
mailing list
