Arithmetic/Complex: Difference between revisions
Content added Content deleted
(→{{header|Smalltalk}}: more examples involving fractions) |
|||
Line 4,491: | Line 4,491: | ||
a negated displayNl.</lang> |
a negated displayNl.</lang> |
||
{{works with|Smalltalk/X}} |
{{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 |
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 real and imaginary 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> |
<lang smalltalk> |
||
|a b| |
|a b| |