Jump to content

Arithmetic/Complex: Difference between revisions

Perl 5: Various improvements. Perl 6: Added.
m (Fixed lang tags.)
(Perl 5: Various improvements. Perl 6: Added.)
Line 1,074:
 
=={{header|Perl}}==
The <code>Math::Complex</code> module provides the functionality ofimplements complex numbersarithmetic.
<lang perl>usemy Math::Complex$a = 1 + 1*i;
my $b = 3.14159 + 1.25*i;
 
print "$_\n" foreach $a + $b, $a * $b, 1 / $a, -$a;</lang>
$a = 1 + 1*i;
$b = 3.14159 + 1.25*i;
 
=={{header|Perl 6}}==
$c = $a + $b;
{{works with|Rakudo|#22 "Thousand Oaks"}}
$c = $a * $b;
 
$c = 1 / $a;
<lang perl6>my $a = 1 + 1i;
$c = -$a;</lang>
my $ab = 1pi + 1*i.25i;
 
.say for $a + $b, $a * $b, 1 / $a, -$a;</lang>
 
=={{header|Pop11}}==
845

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.