Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information