# @printf: significant digits in floating point representation

hi i want tu use @sprintf to format a number to floating point representation with a fixed amount of significant digits
how can I do that?
The function shout act the following way:

.000012340000 -> 0.000012
.123400000000 -> 0.12
1.234 -> 1.2
1234000.000 -> 1200000

best…

I think %.3e or %.3g may be what you’re looking for, which gives scientific notation

…but the problem is, that i want to use this to throw the number against Tikz / PGFplotsX. but LaTeX can not deal with scientific notation very well.

as a last resort, you can always get the string and manipulate that

edit: actually, should have looked at round first

julia> round(pi, digits=3)
3.142

julia> round(pi, sigdigits=3)
3.14
1 Like

Hahaha…. yes this i also had i mind but and the thread ended up in this issue

but now:

julia> round(.000012340000, sigdigits=3)
1.23e-5
julia> @printf "%.f" round(.000012340000, sigdigits=3)
0.000012

well this is slightly wrong too…um, yea just be a string wrangler for now I guess, sorry bud

1 Like