The Trunk: Kernel-nice.1282.mcz

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

The Trunk: Kernel-nice.1282.mcz

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

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

Name: Kernel-nice.1282
Author: nice
Time: 22 November 2019, 5:54:28.478745 pm
UUID: 70d4bc61-04e8-4cfd-befb-1b23f3f13953
Ancestors: Kernel-mt.1281

Let complex print the correct signBit of its imaginary part in case of negativeZero.

Note: the signBit are not preserved upon reinterpretation.
That's a problem of representation via arithmetic operation 1 + 2 i
because we have this
0.0 - 0.0 -> 0.0
0.0 + (-0.0) -> 0.0
(-0.0) + (-0.0) -> -0.0
(-0.0) - 0.0 -> -0.0

=============== Diff against Kernel-mt.1281 ===============

Item was changed:
  ----- Method: Complex>>printOn: (in category 'printing') -----
  printOn: aStream
  real printOn: aStream.
  aStream nextPut: Character space.
+ imaginary signBit = 0
- 0 <= imaginary
  ifTrue: [aStream nextPut: $+]
  ifFalse: [aStream nextPut: $-].
  aStream nextPut: Character space.
  imaginary abs printOn: aStream.
  aStream nextPut: Character space.
  aStream nextPut: $i
  !

Item was changed:
  ----- Method: Complex>>printOn:showingDecimalPlaces: (in category 'printing') -----
  printOn: aStream showingDecimalPlaces: placesDesired
  real printOn: aStream showingDecimalPlaces: placesDesired.
  aStream nextPut: Character space.
+ imaginary signBit = 0
- 0 <= imaginary
  ifTrue: [aStream nextPut: $+]
  ifFalse: [aStream nextPut: $-].
  aStream nextPut: Character space.
  imaginary abs printOn: aStream showingDecimalPlaces: placesDesired.
  aStream nextPut: Character space.
  aStream nextPut: $i
  !


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-nice.1282.mcz

Nicolas Cellier
Additional notes:

The signBit of real part is preserved as long as imaginary prints with sign -.
The signBit of imaginary part is not preserved.

(Complex real: -0.0 imaginary: -0.0) -> (-0.0 - 0.0i) -> (-0.0 + 0.0 i) -> (0.0 + 0.0 i)

(Complex real: -0.0 imaginary: 0.0) -> (-0.0 + 0.0 i) -> ( 0.0 + 0.0 i)

(Complex real: 0.0 imaginary: -0.0) -> (0.0 - 0.0 i) -> ( 0.0 + 0.0 i)

In Smallapack, where I had to print and re-interpret large complex matrices, i had to introduce selector (0.0 i: -0.0).

1. it is more efficient than arithmetic (which counts for large matrices)
2. it preserves the datas (as well as Number printString can preserve)

While 1 + 2 i can look nice and appealing, it gets quite nasty properties regarding above points...

Le ven. 22 nov. 2019 à 17:54, <[hidden email]> a écrit :
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.1282.mcz

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

Name: Kernel-nice.1282
Author: nice
Time: 22 November 2019, 5:54:28.478745 pm
UUID: 70d4bc61-04e8-4cfd-befb-1b23f3f13953
Ancestors: Kernel-mt.1281

Let complex print the correct signBit of its imaginary part in case of negativeZero.

Note: the signBit are not preserved upon reinterpretation.
That's a problem of representation via arithmetic operation 1 + 2 i
because we have this
0.0 - 0.0 -> 0.0
0.0 + (-0.0) -> 0.0
(-0.0) + (-0.0) -> -0.0
(-0.0) - 0.0 -> -0.0

=============== Diff against Kernel-mt.1281 ===============

Item was changed:
  ----- Method: Complex>>printOn: (in category 'printing') -----
  printOn: aStream
        real printOn: aStream.
        aStream nextPut: Character space.
+       imaginary signBit = 0
-       0 <= imaginary
                ifTrue: [aStream nextPut: $+]
                ifFalse: [aStream nextPut: $-].
        aStream nextPut: Character space.
        imaginary abs printOn: aStream.
        aStream nextPut: Character space.
        aStream nextPut: $i
  !

Item was changed:
  ----- Method: Complex>>printOn:showingDecimalPlaces: (in category 'printing') -----
  printOn: aStream showingDecimalPlaces: placesDesired
        real printOn: aStream showingDecimalPlaces: placesDesired.
        aStream nextPut: Character space.
+       imaginary signBit = 0
-       0 <= imaginary
                ifTrue: [aStream nextPut: $+]
                ifFalse: [aStream nextPut: $-].
        aStream nextPut: Character space.
        imaginary abs printOn: aStream showingDecimalPlaces: placesDesired.
        aStream nextPut: Character space.
        aStream nextPut: $i
  !