Trying to replicate the following C printf invocation
printf("%6.1f %6.1f %6.1f\n", x, y, z);
in rust and I can't find it in the docs. I need 6 positions wide with 1 decimal place.
First time I've been stumped finding what I need there.
Formatting strings are documented in the documentation for std::fmt
.
The equivalent of %6.1f
would be {:6.1}
:
println!("{:6.1} {:6.1} {:6.1}", x, y, z);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.