Browse Source

Add unit notation chapter

David Peter 2 years ago
parent
commit
74baf97f2b
3 changed files with 34 additions and 3 deletions
  1. 1 1
      book/src/SUMMARY.md
  2. 4 2
      book/src/list-units.md
  3. 29 0
      book/src/unit-notation.md

+ 1 - 1
book/src/SUMMARY.md

@@ -22,7 +22,7 @@
 
 - [Basics](./basics.md)
   - [Number notation](./number-notation.md)
-  - [Unit notation]()
+  - [Unit notation](./unit-notation.md)
   - [Operators and their precedence](./operators.md)
   - [Unit conversions](./unit-conversions.md)
   - [Printing, testing, debugging](./procedures.md)

+ 4 - 2
book/src/list-units.md

@@ -1,7 +1,9 @@
 # List of supported units
 
-All SI-accepted units support [metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix) (`mm`, `cm`, `km`, ... or `millimeter`, `centimeter`, `kilometer`, ...) and, where sensible, units allow for
-[binary prefixes](https://en.wikipedia.org/wiki/Binary_prefix) (`MiB`, `GiB`, ... or `mebibyte`, `gibibyte`, ...).
+See also: [Unit notation](./unit-notation.md).
+
+All SI-accepted units support [metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix) (`mm`, `cm`, `km`, ... or `millimeter`, `centimeter`, `kilometer`, ...)
+and — where sensible — units allow for [binary prefixes](https://en.wikipedia.org/wiki/Binary_prefix) (`MiB`, `GiB`, ... or `mebibyte`, `gibibyte`, ...).
 
 | Unit | Syntax |
 | ---- | ------ |

+ 29 - 0
book/src/unit-notation.md

@@ -0,0 +1,29 @@
+# Unit notation
+
+Most units can be entered in the same way that they would appear in textbook calculations. They
+usually have a long form (`meter`, `degrees`, `byte`, …), a plural form (`meters`, `degrees`, `bytes`),
+and a short alias (`m`, `°`, `B`). For a full list of supported units, see
+[this page](./list-units.md).
+
+All SI-accepted units support [metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix) (`mm`, `cm`, `km`, ... or `millimeter`, `centimeter`, `kilometer`, ...)
+and — where sensible — units allow for [binary prefixes](https://en.wikipedia.org/wiki/Binary_prefix) (`MiB`, `GiB`, ... or `mebibyte`, `gibibyte`, ...). Note
+that the short-form prefixes can only be used with the short version of the unit, and vice versa (that is: `kmeter` and `kilom` are *not* allowed, only `km` and `kilometer`).
+
+Units can be combined using [mathematical operations](./operators.md) such as multiplication, division and exponentiation: `kg * m/s^2`, `km/h`, `m²`, `meter per second`.
+
+The following snippet shows various styles of entering units:
+```nbt
+2 min + 1 s
+150 cm
+sin(30°)
+50 mph
+6 MiB
+
+2 minutes + 1 second
+150 centimeters
+sin(30 degrees)
+50 miles per hour
+6 mebibyte
+```
+
+Note that Numbat also allows you to [define new units](./unit-definitions.md).