realPart = (float) $realPart; $this->imaginaryPart = (float) $imaginaryPart; $this->suffix = strtolower($suffix); } public function getReal() { return $this->realPart; } public function getImaginary() { return $this->imaginaryPart; } public function getSuffix() { return $this->suffix; } public function __toString() { $str = ""; if ($this->imaginaryPart != 0.0) { if (abs($this->imaginaryPart) != 1.0) { $str .= $this->imaginaryPart . $this->suffix; } else { $str .= (($this->imaginaryPart < 0.0) ? '-' : ''). $this->suffix; } } if ($this->realPart != 0.0) { if (($str) && ($this->imaginaryPart > 0.0)) { $str = "+" . $str; } $str = $this->realPart . $str; } if (!$str) { $str = "0.0"; } return $str; } }