From 3a94fee918e17541a41c156fd95c7a83e03f0ecc Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Wed, 7 Jul 2021 11:12:24 +0200 Subject: [PATCH] A tip for specifying precision of displayed quantities. I've spent about half an hour figuring it out so I think this tip may be useful for other people :slightly_smiling_face: . --- docs/src/display.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/src/display.md b/docs/src/display.md index a1f016d8..7416216e 100644 --- a/docs/src/display.md +++ b/docs/src/display.md @@ -6,6 +6,20 @@ variable `UNITFUL_FANCY_EXPONENTS` to either `true` or `false` to force using or the exponents. You can also set the `:fancy_exponent` IO context property to either `true` or `false` to force using or not using the exponents. +## Specifying precision + +If you need to set precision of displayed value of your unitful quantity, you can use the +`round` function as follows: + +```julia +julia> d = 1.7438748921932u"mm" +1.7438748921932 mm + +julia> round(typeof(d), d; sigdigits=3) +1.74 mm +``` + + ```@docs Unitful.BracketStyle Unitful.abbr