A tip for specifying precision of displayed quantities.#460
A tip for specifying precision of displayed quantities.#460mateuszbaran wants to merge 1 commit intoJuliaPhysics:masterfrom
Conversation
I've spent about half an hour figuring it out so I think this tip may be useful for other people 🙂 .
|
I think the wording here is misleading: I think it would be good to add a section about rounding. In that section, we could explain why it is necessary to specify the output unit (or is it obvious enough?). Note that you can also specify a unit instead of a type as first argument. We should document this as well: julia> round(typeof(d), d; sigdigits=3)
1.74 mm
julia> round(u"mm", d; sigdigits=3)
1.74 mm
julia> round(u"m", d; sigdigits=3)
0.00174 m |
|
"set precision of displayed value" is the thing I wanted to do, so to me this is the key part that needs documenting. If you thing this should be done differently than using |
|
I had a quantity that, when printed it to a string, it gave me way too many digits, more than the precision with which the quantity was determined. So it looked silly and I wanted to trim it -- and it's definitely not obvious how it should be done. |
I've spent about half an hour figuring it out so I think this tip may be useful for other people 🙂 .