The Trunk: Kernel.spur-nice.921.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel.spur-nice.921.mcz

commits-2
Chris Muller uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel.spur-nice.921.mcz

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

Name: Kernel.spur-nice.921
Author: eem
Time: 12 May 2015, 3:31:59.091 pm
UUID: b0a4cf6f-4899-4f58-9173-23eb5e4738c3
Ancestors: Kernel-nice.921, Kernel.spur-topa.920

Kernel-nice.921 patched for Spur by SpurBootstrapMonticelloPackagePatcher Cog-eem.267

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.spur-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: InstructionClient>>callPrimitive: (in category '*Scorch') -----
+ callPrimitive: pimIndex
+ "V3PlusClosures: 139 10001011 iiiiiiii   jjjjjjjj  Call Primitive #iiiiiiii + (jjjjjjjj * 256)
+ NewsqueakV4: 249 11111001 iiiiiiii   jjjjjjjj  Call Primitive #iiiiiiii + (jjjjjjjj * 256)
+ SistaV1: 248 11111000 iiiiiiii mjjjjjjj  Call Primitive #iiiiiiii + ( jjjjjjj * 256)
+ m=1 means inlined primitive, no hard return after execution."!

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!