[squeak-dev] The Trunk: Kernel-nice.730.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Jan 17 22:32:17 UTC 2013


Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.730.mcz

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

Name: Kernel-nice.730
Author: nice
Time: 9 January 2013, 3:13:24.184 am
UUID: a5bc2c5c-0e3e-428c-8fc4-b0cd633be9f4
Ancestors: Kernel-nice.729

1) connect primitive 20 for large integer modulo (in range 31 to 64 bits)
2) simplify #digitDiv:neg: senders since it can cope with a negative SmallInteger as first parameter

WARNING: do not use with COG 2662 because primitive 20 (rem) is broken for negative case.
This will have to wait a few days in the inbox...

NOTE: the fallback code for Euclidean division #digitDiv:neg: is awfully dated with its nibbles... our (positive) SmallInteger range is 30bits.

=============== Diff against Kernel-nice.729 ===============

Item was changed:
  ----- Method: Integer>>/ (in category 'arithmetic') -----
  / aNumber
  	"Refer to the comment in Number / "
  	| quoRem |
  	aNumber isInteger ifTrue:
+ 		[quoRem := self digitDiv: aNumber neg: self negative ~~ aNumber negative.
- 		[quoRem := self digitDiv: aNumber abs	"*****I've added abs here*****"
- 						neg: self negative ~~ aNumber negative.
  		(quoRem at: 2) = 0
  			ifTrue: [^ (quoRem at: 1) normalize]
  			ifFalse: [^ (Fraction numerator: self denominator: aNumber) reduced]].
  	^ aNumber adaptToInteger: self andSend: #/!

Item was changed:
  ----- Method: Integer>>quo: (in category 'arithmetic') -----
  quo: aNumber 
  	"Refer to the comment in Number quo: "
  	| ng quo |
  	aNumber isInteger ifTrue: 
  		[ng := self negative == aNumber negative == false.
+ 		quo := (self digitDiv: aNumber neg: ng) at: 1.
- 		quo := (self digitDiv:
- 			(aNumber class == SmallInteger
- 				ifTrue: [aNumber abs]
- 				ifFalse: [aNumber])
- 			neg: ng) at: 1.
  		^ quo normalize].
  	^ aNumber adaptToInteger: self andSend: #quo:!

Item was changed:
  ----- Method: LargePositiveInteger>>\\ (in category 'arithmetic') -----
  \\ aNumber 
  	"Primitive. Take the receiver modulo the argument. The result is the
  	remainder rounded towards negative infinity, of the receiver divided
  	by the argument. Fail if the argument is 0. Fail if either the argument
  	or the result is not a SmallInteger or a LargePositiveInteger less than
  	2-to-the-30th (1073741824). Optional. See Object documentation whatIsAPrimitive."
  
  	<primitive: 31>
  	aNumber isInteger
  		ifTrue:
  			[| neg qr q r |
  			neg := self negative == aNumber negative == false.
+ 			qr := self digitDiv: aNumber neg: neg.
- 			qr := (self digitDiv:
- 				(aNumber class == SmallInteger
- 					ifTrue: [aNumber abs]
- 					ifFalse: [aNumber])
- 				neg: neg).
  			q := qr first normalize.
  			r := qr last normalize.
  			^(q negative
  				ifTrue: [r isZero not]
  				ifFalse: [q isZero and: [neg]])
  					ifTrue: [r + aNumber]
  					ifFalse: [r]].
  	^super \\ aNumber
  	!

Item was removed:
- ----- Method: LargePositiveInteger>>primitiveQuo: (in category 'private') -----
- primitiveQuo: anInteger 
- 	"Primitive. Divide the receiver by the argument and return the result.
- 	Round the result down towards zero to make it a whole integer. Fail if
- 	the argument is 0. Fail if either the argument or the result is not a
- 	SmallInteger or a LargePositiveInteger less than 2-to-the-30th (1073741824). Optional. See
- 	Object documentation whatIsAPrimitive."
- 
- 	<primitive: 33>
- 	^nil!

Item was changed:
  ----- Method: LargePositiveInteger>>rem: (in category 'arithmetic') -----
  rem: aNumber 
  	"Remainder defined in terms of quo:. See super rem:.
+ 	This is defined only to speed up case of large integers."
- 	This is defined only to speed up case of very large integers."
  
+ 	<primitive: 20>
- 	(self primitiveQuo: aNumber)
- 		ifNotNil: [:quo | ^self - (quo * aNumber)].
  	 aNumber isInteger
  		ifTrue:
  			[| ng rem |
  			ng := self negative == aNumber negative == false.
+ 			rem := (self digitDiv: aNumber neg: ng) at: 2.
- 			rem := (self digitDiv:
- 				(aNumber class == SmallInteger
- 					ifTrue: [aNumber abs]
- 					ifFalse: [aNumber])
- 				neg: ng) at: 2.
  			^ rem normalize].
  	^super rem: aNumber!



More information about the Squeak-dev mailing list