You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
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>using Formatting, Printf
julia>sprintf1("p=%.1f", 20)
ERROR: Only one AND undecorated format string is allowed
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] checkfmt at /Users/qz/.julia/packages/Formatting/BwWBf/src/cformat.jl:12 [inlined]
[3] generate_formatter(::String) at /Users/qz/.julia/packages/Formatting/BwWBf/src/cformat.jl:23
[4] sprintf1(::String, ::Int64) at /Users/qz/.julia/packages/Formatting/BwWBf/src/cformat.jl:3
[5] top-level scope at REPL[12]:1
julia>@sprintf("p=%.1f", 20)
"p=20.0"
julia>versioninfo()
Julia Version 1.4.2
Commit 44fa15b150* (2020-05-2318:35 UTC)
But it does work on Julia 1.6+:
julia>sprintf1("p=%.1f", 20)
"p=20.0"
julia>versioninfo()
Julia Version 1.7.2
Commit bf53498635 (2022-02-0615:21 UTC)
As you can see, @sprintf actually has a wider range of "%Fmt" that it can take. Can I still do that with a C-style format specification string in Formatting.jl?
The text was updated successfully, but these errors were encountered:
singularitti
changed the title
Can sprintf1 format something like "p=%.1f"?sprintf1 can format C-style format specification string like "p=%.1f" in Julia 1.6+ but cannot do it on Julia 1.4
Apr 18, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
As the title suggests, I want to print a string like
"p=20.0"
usingsprintf1
with a C-style format specification string. For example,But it does work on Julia 1.6+:
As you can see,
@sprintf
actually has a wider range of"%Fmt"
that it can take. Can I still do that with a C-style format specification string inFormatting.jl
?The text was updated successfully, but these errors were encountered: