[Pkg] The Trunk: Kernel-nice.634.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Oct 13 22:35:23 UTC 2011
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.634.mcz
==================== Summary ====================
Name: Kernel-nice.634
Author: nice
Time: 14 October 2011, 12:34:15.894 am
UUID: ec28e2e7-ee3e-41a9-9eed-dd75acc1a7cf
Ancestors: Kernel-eem.633
Move Complex conversion (#asComplex #adaptToComplex:andSend:) one level upper in Number.
Use squared where possible in Complex.
=============== Diff against Kernel-eem.633 ===============
Item was changed:
----- Method: Complex>>raisedToInteger: (in category 'mathematical functions') -----
raisedToInteger: operand
"Answer the receiver raised to the power operand, an Integer."
"implementation note: this code is copied from Number.
This suggest that both Number and Complex should have an
ArithmeticValue common superclass like in Visualworks.
Or maybe should it be a Traits (a property of fields ?)"
| count result |
operand isInteger ifFalse: [^ ArithmeticError signal: 'parameter is not an Integer'].
operand = 0 ifTrue: [^ self class one].
operand = 1 ifTrue: [^ self].
operand < 0 ifTrue: [^ (self raisedToInteger: operand negated) reciprocal].
count := 1 bitShift: (operand-1) highBit.
result := self class one.
[count > 0]
whileTrue:
+ [result := result squared.
- [result := result * result.
(operand bitAnd: count)
= 0 ifFalse: [result := result * self].
count := count bitShift: -1].
^ result!
Item was removed:
- ----- Method: Float>>adaptToComplex:andSend: (in category 'converting') -----
- adaptToComplex: rcvr andSend: selector
- "If I am involved in arithmetic with a Complex number, convert me to a Complex number."
- ^ rcvr perform: selector with: self asComplex!
Item was removed:
- ----- Method: Float>>asComplex (in category 'converting') -----
- asComplex
- "Answer a Complex number that represents value of the the receiver."
-
- ^ Complex real: self imaginary: 0!
Item was removed:
- ----- Method: Fraction>>adaptToComplex:andSend: (in category 'converting') -----
- adaptToComplex: rcvr andSend: selector
- "If I am involved in arithmetic with a Complex number, convert me to a Complex number."
- ^ rcvr perform: selector with: self asComplex!
Item was removed:
- ----- Method: Fraction>>asComplex (in category 'converting') -----
- asComplex
- "Answer a Complex number that represents value of the the receiver."
-
- ^ Complex real: self imaginary: 0!
Item was removed:
- ----- Method: Integer>>adaptToComplex:andSend: (in category 'converting') -----
- adaptToComplex: rcvr andSend: selector
- "If I am involved in arithmetic with a Complex number, convert me to a Complex number."
- ^ rcvr perform: selector with: self asComplex!
Item was removed:
- ----- Method: Integer>>asComplex (in category 'converting') -----
- asComplex
- "Answer a Complex number that represents value of the the receiver."
-
- ^ Complex real: self imaginary: 0!
Item was added:
+ ----- Method: Number>>adaptToComplex:andSend: (in category 'converting') -----
+ adaptToComplex: rcvr andSend: selector
+ "If I am involved in arithmetic with a Complex number, convert me to a Complex number."
+ ^ rcvr perform: selector with: self asComplex!
Item was added:
+ ----- Method: Number>>asComplex (in category 'converting') -----
+ asComplex
+ "Answer a Complex number that represents value of the the receiver."
+
+ ^ Complex real: self imaginary: 0!
More information about the Packages
mailing list