Complex.st
changeset 23134 b6056d446cd8
parent 22938 c3954250f7e7
child 23167 3d8ef4a8970d
equal deleted inserted replaced
23133:6db5c28207d5 23134:b6056d446cd8
    74         6 + 7 i.
    74         6 + 7 i.
    75         5.6 - 8 i.
    75         5.6 - 8 i.
    76         Complex real: 10 imaginary: 5.
    76         Complex real: 10 imaginary: 5.
    77         Complex abs: 5 arg: (Float pi / 4)
    77         Complex abs: 5 arg: (Float pi / 4)
    78 
    78 
    79     NOTE: 
    79     NOTE (from the original author): 
    80         Although Complex something similiar to the Smalltalk''s Number class, 
    80         Although Complex seems similiar to the Smalltalk''s Number class, 
    81         it would not be a good idea to make a Complex to be a subclass of a Number because:
    81         it would not be a good idea to make a Complex to be a subclass of a Number because:
    82             - Number is subclass of Magnitude and Complex is certainly not a magnitude.
    82             - Number is subclass of Magnitude and Complex is certainly not a magnitude.
    83               Complex does not behave very well as a Magnitude. Operations such as
    83               Complex does not behave very well as a Magnitude. Operations such as
    84                 <
    84                 <
    85                 >
    85                 >
   983     self imaginaryPart abs printOn: aGCOrStream.
   983     self imaginaryPart abs printOn: aGCOrStream.
   984     aGCOrStream nextPutAll: 'i)'
   984     aGCOrStream nextPutAll: 'i)'
   985 
   985 
   986     "
   986     "
   987      Complex real:1 imaginary:1
   987      Complex real:1 imaginary:1
       
   988      (Complex real:1 imaginary:1) printString
       
   989      (Complex real:1 imaginary:1) displayString
   988     "
   990     "
   989 
   991 
   990     "Modified (format): / 22-02-2017 / 17:01:02 / cg"
   992     "Modified (format): / 22-02-2017 / 17:01:02 / cg"
       
   993     "Modified (comment): / 26-06-2018 / 21:00:28 / Claus Gittinger"
   991 !
   994 !
   992 
   995 
   993 printOn: aStream
   996 printOn: aStream
   994     aStream nextPut: $(.
   997     aStream nextPut: $(.
   995     real storeOn: aStream.
   998     real storeOn: aStream.