Arithmetic/Complex: Difference between revisions

(→‎{{header|Smalltalk}}: more examples involving fractions)
Line 4,491:
a negated displayNl.</lang>
{{works with|Smalltalk/X}}
Complex is already in the basic class library. Multiples of imaginary are created by sending an "i" message to a number, which can be added to another number. Thus 5i => (0+5i), 1+(1/3)I => (1+1/3i) and (1.0+2i) => (1.0+2i). Notice that the readreal and imageimaginary components can be arbitrary integers, fractions or floating point numbers. And the results will be exact (i.e. have fractions or integer) if possible.
<lang smalltalk>
|a b|
Anonymous user