Formatting.jl
Formatting.jl copied to clipboard
Deprecated. See README. (A Julia package to provide Python-like formatting support)
As the title suggests, I want to print a string like `"p=20.0"` using `sprintf1` with a C-style format specification string. For example, ```julia julia> using Formatting, Printf julia> sprintf1("p=%.1f", 20)...
It is shown clearly as an actual example in the Python formatting specification shown. It doesn't work.
When no decimal digits are requested, no decimal digits are formatted, but the decimal point is still included. This is different from printf in C and from format in Python,...
- Improved string safety by using `SubString`, `prevind`, `nextind`, `firstindex`, and `lastindex` where possible. - Made performance improvements by changing `findfirst(isequal(c), str)` to `findfirst(c, str)` (no allocating, much faster), and...
Add the ability to change the default thousands separator. ```julia julia> using Formatting julia> Formatting.THOUSANDS_SEPARATOR[] = ' '; julia> format(1_000_000, commas=true) "1 000 000" ``` No performance penalty observed. Fix...
```julia julia> using Formatting julia> fmt = FormatExpr("{1:+11.3e}") FormatExpr("", "", Formatting.FormatEntry[Formatting.FormatEntry(Formatting.ArgSpec(1, false, identity), FormatSpec cls = f typ = e fill = align = > sign = + width =...
https://github.com/JuliaIO/Formatting.jl/blob/e4c9f60020e965a72abae049ddac7e02bf986067/src/fmtcore.jl#L176 ```julia julia> using Formatting julia> fmt(FormatSpec("15.6f"), 1e5) # OK " 100000.000000" julia> fmt(FormatSpec("15.6f"), 1e10) # OK, even the width is too small "10000000000.000000" julia> fmt(FormatSpec("15.6f"), 1e20) # Error, the...
`printfmt("1:.4e, 40000.0)` should print `4.0000e+04`, but it prints `3.10000e+04`.