From 11a539cabcb4bd6d6e65f6f9478273e78eb18b4b Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 13 Sep 2023 08:59:29 +0200 Subject: [PATCH] docs: units composition FAQ cleanup --- docs/getting_started/faq.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/getting_started/faq.md b/docs/getting_started/faq.md index a3dd5123..dcbb2715 100644 --- a/docs/getting_started/faq.md +++ b/docs/getting_started/faq.md @@ -105,8 +105,11 @@ auto q = 60 * km / 2 * h; ``` Looks like `30 km/h`, right? But it is not. If the above code was allowed, it would result -in `30 km⋅h`. In case you want to divide `60 * km` by `2 * h` a parenthesis is needed -`60 * km / (2 * h)`. +in `30 km⋅h`. In case you want to divide `60 * km` by `2 * h` a parenthesis is needed: + +```cpp +auto q = 60 * km / (2 * h); +``` Another surprising issue could result from the following code: @@ -126,7 +129,8 @@ auto v = 42 * m; auto q = make_length(v); ``` -Fortunately, with the current design, such issues are detected at compile-time. +Fortunately, with the current design, such issues are detected at compile-time as +multiplying or dividing a quantity by a unit is not be supported. ## Why a dimensionless quantity is not just a fundamental arithmetic type?