summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAngel Ezquerra <AngelEzquerra@users.noreply.github.com>2023-11-10 05:29:55 +0100
committerGitHub <noreply@github.com>2023-11-10 05:29:55 +0100
commit52784f32bbb6c764eb67a1abdbbbd9f54dc6030e (patch)
tree2c6aa1f94785e52f65d7e7142297289a94dc80b0 /tests
parent60597adb1019174fe190ff84e46284a72a8b1ae2 (diff)
downloadNim-52784f32bbb6c764eb67a1abdbbbd9f54dc6030e.tar.gz
Add strformat support for Complex numbers (#22924)
Before this change strformat used the generic formatValue function for
Complex numbers. This meant that it was not possible to control the
format of the real and imaginary components of the complex numbers.

With this change this now works:
```nim
import std/[complex, strformat]
let c = complex(1.05000001, -2.000003)
echo &"{c:g}"
# You now get: (1.05, -2)
# while before you'd get a ValueError exception (invalid type in format string for string, expected 's', but got g)
```

The only small drawback of this change is that I had to import complex
from strformat. I hope that is not a problem.

---------

Co-authored-by: Angel Ezquerra <angel_ezquerra@keysight.com>
Diffstat (limited to 'tests')
0 files changed, 0 insertions, 0 deletions