[Pkg] The Trunk: Kernel-nice.499.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Sep 21 22:10:02 UTC 2010
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.499.mcz
==================== Summary ====================
Name: Kernel-nice.499
Author: nice
Time: 22 September 2010, 12:09:25.27 am
UUID: a30fc6fb-96fb-427a-af36-cf4594848eee
Ancestors: Kernel-nice.498
Fix the tricky cases of the copy sign function (#sign:) in case of Float negativeZero
=============== Diff against Kernel-nice.498 ===============
Item was added:
+ ----- Method: Float>>copySignTo: (in category 'mathematical functions') -----
+ copySignTo: aNumber
+ "Return a number with same magnitude as aNumber and same sign as self.
+ Implementation note: take care of Float negativeZero, which is considered as having a negative sign."
+
+ (self > 0 or: [(self at: 1) = 0]) ifTrue: [^ aNumber abs].
+ ^aNumber abs negated!
Item was changed:
+ ----- Method: Float>>sign (in category 'mathematical functions') -----
- ----- Method: Float>>sign (in category 'testing') -----
sign
"Answer 1 if the receiver is greater than 0, -1 if less than 0, else 0.
Handle IEEE-754 negative-zero by reporting a sign of -1"
self > 0 ifTrue: [^ 1].
(self < 0 or: [((self at: 1) bitShift: -31) = 1]) ifTrue: [^ -1].
^ 0!
Item was added:
+ ----- Method: Float>>sign: (in category 'mathematical functions') -----
+ sign: aNumber
+ "Return a Number with the same sign as aNumber and same magnitude as self.
+ Implementation is different from super to handle the special case of Float negativeZero."
+
+ (self = 0.0 and: [aNumber sign negative]) ifTrue: [^Float negativeZero].
+ ^aNumber copySignTo: self!
Item was added:
+ ----- Method: Number>>copySignTo: (in category 'mathematical functions') -----
+ copySignTo: aNumber
+ "Return a number with same magnitude as aNumber and same sign as self."
+
+ ^ self positive
+ ifTrue: [aNumber abs]
+ ifFalse: [aNumber abs negated].!
Item was changed:
+ ----- Method: Number>>sign (in category 'mathematical functions') -----
- ----- Method: Number>>sign (in category 'testing') -----
sign
"Answer 1 if the receiver is greater than 0, -1 if less than 0, else 0."
self > 0 ifTrue: [^1].
self < 0 ifTrue: [^-1].
^0!
Item was changed:
+ ----- Method: Number>>sign: (in category 'mathematical functions') -----
- ----- Method: Number>>sign: (in category 'converting') -----
sign: aNumber
+ "Return a Number with the same sign as aNumber and same magnitude as self."
- "Return a Number with the same sign as aNumber"
+ ^ aNumber copySignTo: self!
- ^ aNumber positive ifTrue: [self abs] ifFalse: [self abs negated].!
More information about the Packages
mailing list