printComplex outputs a complex value using the specified float precision for the real and imaginary parts to Writer w.
(w io.Writer, c complex128, floatPrecision int)
| 168 | // printComplex outputs a complex value using the specified float precision |
| 169 | // for the real and imaginary parts to Writer w. |
| 170 | func printComplex(w io.Writer, c complex128, floatPrecision int) { |
| 171 | r := real(c) |
| 172 | w.Write(openParenBytes) |
| 173 | w.Write([]byte(strconv.FormatFloat(r, 'g', -1, floatPrecision))) |
| 174 | i := imag(c) |
| 175 | if i >= 0 { |
| 176 | w.Write(plusBytes) |
| 177 | } |
| 178 | w.Write([]byte(strconv.FormatFloat(i, 'g', -1, floatPrecision))) |
| 179 | w.Write(iBytes) |
| 180 | w.Write(closeParenBytes) |
| 181 | } |
| 182 | |
| 183 | // printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x' |
| 184 | // prefix to Writer w. |