From 9b7723517cdb1ce2091d8b5f865b086a2878bd1e Mon Sep 17 00:00:00 2001 From: KronosTheLate <61620837+KronosTheLate@users.noreply.github.com> Date: Fri, 4 Jun 2021 17:45:58 +0200 Subject: [PATCH] Showing how to manually cancel units (#451) * Showing how to manually cancel units * Update conversion.md added the statement that `m/m` is automatically canceled * Remove contrived examples, fixed typo * More clear example This commit changes the expression from which units are shortened to 1km/2.5m, to make clear that the denomenator is part of the expression. It also fixed a typo (`NoUnit -> NoUnits`) * Shorten example It seems like some of the examples did not sit well with some of the contributers. I see their point completely, and in this PR I have made the example minimal and clearer. #LessIsMore * Added @ref, and more interesting example I added a reference to the NoUnits type (hopefully - I don't know how to chech that the reference actually works as expected). I also changed the example to the more complicated one, to make it less trivial and hopefully better showcase the usefullness. * Update docs/src/conversion.md Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> * As per the latest review, which got outdated Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- docs/src/conversion.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/src/conversion.md b/docs/src/conversion.md index 84e59dc4..2c2e56c9 100644 --- a/docs/src/conversion.md +++ b/docs/src/conversion.md @@ -299,3 +299,11 @@ For multiplication and division, note that powers-of-ten prefixes are significan in unit cancellation. For instance, `mV/V` is not simplified, although `V/V` is. Also, `N*m/J` is not simplified: there is currently no logic to decide whether or not units on a dimensionless quantity seem "intentional" or not. +It is however possible to cancel units manually, by passing the dimensionless +quantity to the [`NoUnits`](@ref) constructor. This takes into account different SI-prefixes: +```jldoctest +julia> using Unitful + +julia> julia> 1u"kN*m"/4u"J" |> NoUnits +250.0 +```