RosettaCodeData/Task/Arithmetic-Complex/PowerShell/arithmetic-complex-2.psh

17 lines
624 B
Text
Raw Permalink Normal View History

2016-12-05 22:15:40 +01:00
function show([System.Numerics.Complex]$c) {
2017-09-23 10:01:46 +02:00
if(0 -le $c.Imaginary) {
2016-12-05 22:15:40 +01:00
return "$($c.Real)+$($c.Imaginary)i"
} else {
return "$($c.Real)$($c.Imaginary)i"
}
}
$m = [System.Numerics.Complex]::new(3, 4)
$n = [System.Numerics.Complex]::new(7, 6)
"`$m: $(show $m)"
"`$n: $(show $n)"
"`$m + `$n: $(show ([System.Numerics.Complex]::Add($m,$n)))"
"`$m * `$n: $(show ([System.Numerics.Complex]::Multiply($m,$n)))"
"negate `$m: $(show ([System.Numerics.Complex]::Negate($m)))"
"1/`$m: $(show ([System.Numerics.Complex]::Reciprocal($m)))"
"conjugate `$m: $(show ([System.Numerics.Complex]::Conjugate($m)))"