Skip to content

Commit

Permalink
Showing how to manually cancel units (#451)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
KronosTheLate and sostock authored Jun 4, 2021
1 parent 3ec4b02 commit 9b77235
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/src/conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

0 comments on commit 9b77235

Please sign in to comment.