Skip to content

Commit 747d7bf

Browse files
Update KCL docs (#578)
YOYO NEW KCL DOCS!! Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 2f5fefa commit 747d7bf

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

content/pages/docs/kcl-lang/numeric.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ KCL has no support for area, volume, or other higher dimension units. When inter
4646
## Explicit conversions
4747

4848
You might sometimes need to convert from one unit to another for some calculation. You can do this implicitly when calling a function (see above), but if you can't or don't want to, then you can use the explicit conversion functions in the [`std::units`](/docs/kcl-std/modules/std-units) module.
49+
50+
KCL cannot know about changes to units caused by arithmetic. For example, you may intend for `10in * 25.4` to be the value `254mm` (i.e., `10in` in mm), however, the result of that computation in KCL is `254in`. It is always better to rely on automatic conversion or to use the explicit conversion functions, where possible.
51+
52+
Converting between degrees and radians using π ([`PI`](/docs/kcl-std/consts/std-math-PI) in KCL) is especially prone to this error and so the `PI` constant always requires specifying units of any computation it is used with. E.g., `radius = (circumference / (2 * PI)): number(mm)`.

content/pages/docs/kcl-std/consts/std-math-PI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ However, `PI` is nearly always used for converting between different units - usu
1616
from radians. Therefore, `PI` is treated a bit specially by KCL and always has unknown units. This
1717
means that if you use `PI`, you will need to give KCL some extra information about the units of numbers.
1818
Usually you should use type ascription on the result of calculations, e.g., `(2 * PI): number(rad)`.
19-
You might prefer to use `units::toRadians` or `units::toDegrees` to convert between angles with
20-
different units.
19+
It is better to use `units::toRadians` or `units::toDegrees` to convert between angles with
20+
different units where possible.
2121

2222
### Examples
2323

0 commit comments

Comments
 (0)