Nicolas Cellier uploaded a new version of Kernel to project The Trunk: http://source.squeak.org/trunk/Kernel-nice.921.mcz
==================== Summary ====================
Name: Kernel-nice.921 Author: nice Time: 1 May 2015, 3:09:15.528 pm UUID: 1ce76bf5-1e32-4d12-b7b1-9f23a75d37b2 Ancestors: Kernel-topa.920
Provide an exact version for #floorLog: for those Number using exact arithmetic (as proposed in inbox Kernel-nice.721 / 11 December 2012).
Previous version was not exact, otherwise this count would have been zero: (-300 to: -1) count: [:n | n ~= ((10 raisedTo: n) floorLog: 10)].
Note that this won't make #log: exact, and could lead to disagreement between the two functions. However, old behavior compatible with log: is still possible by passing the radix argument asFloat, so this is not a real problem.
=============== Diff against Kernel-topa.920 ===============
Item was added: + ----- Method: Fraction>>floorLog: (in category 'mathematical functions') ----- + floorLog: radix + "Unlike super, this version is exact when radix is integer" + + | d n | + radix isInteger ifFalse: [^super floorLog: 10]. + n := numerator floorLog: radix. + d := denominator floorLog: radix. + ^(numerator * (radix raisedTo: d)) + < (denominator * (radix raisedTo: n)) + ifTrue: [n - d - 1] + ifFalse: [n - d]!
Item was added: + ----- Method: Integer>>floorLog: (in category 'mathematical functions') ----- + floorLog: radix + "Unlike super, this version is exact when radix is integer" + + radix isInteger ifFalse: [^super floorLog: 10]. + self <= 0 ifTrue: [^DomainError signal: 'floorLog: is only defined for x > 0.0']. + ^(self numberOfDigitsInBase: radix) - 1!
Item was added: + ----- Method: ScaledDecimal>>floorLog: (in category 'mathematical functions') ----- + floorLog: radix + "Unlike super, this version is exact when radix is integer" + + ^self asFraction floorLog: radix!
squeak-dev@lists.squeakfoundation.org