aboutsummaryrefslogtreecommitdiff
path: root/docs/integers.md
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-11-29 15:56:02 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-11-29 15:56:02 -0500
commit97047cb95a88228ddefbc83b4c50b05eaf048272 (patch)
treefb6a57ef6c6fd8e18aba8b8c3e3c6bbf83d61ec6 /docs/integers.md
parentd60962ab5de970a9ce0893df4154b8a0b3ea646a (diff)
Update docs
Diffstat (limited to 'docs/integers.md')
-rw-r--r--docs/integers.md31
1 files changed, 13 insertions, 18 deletions
diff --git a/docs/integers.md b/docs/integers.md
index 6be96880..877ab39d 100644
--- a/docs/integers.md
+++ b/docs/integers.md
@@ -37,8 +37,7 @@ The simplest form of integer literal is a string of digits, which is inferred
to have type `Int` (unbounded size).
```tomo
->>> 123456789012345678901234567890
-= 123456789012345678901234567890 : Int
+i := 123456789012345678901234567890
```
Underscores may also be used to visually break up the integer for readability:
@@ -79,12 +78,10 @@ quotient := numerator / denominator
remainder := numerator mod denominator
# Modulus always gives a non-negative result:
->> remainder >= 0
-= yes
+assert remainder >= 0
# The numerator can be reconstructed sensibly:
->> numerator == denominator * quotient + remainder
-= yes
+assert numerator == denominator * quotient + remainder
```
Importantly, these invariants hold for both positive and negative numerators
@@ -95,25 +92,23 @@ negative numbers are involved. Integer division rounds _down_ instead of
rounding _towards zero_, and modulus never gives negative results:
```tomo
->> quotient := -1 / 5
-= -1
+quotient := -1 / 5
+assert quotient == -1
->> remainder := -1 mod 5
-= 4
+remainder := -1 mod 5
+assert remainder == 4
->> -1 == 5 * -1 + 4
-= yes
+assert -1 == 5 * -1 + 4
```
```tomo
->> quotient := 16 / -5
-= -3
+quotient := 16 / -5
+assert quotient == -3
->> remainder := -1 mod 5
-= 1
+remainder := -1 mod 5
+assert remainder == 1
->> 16 == -5 * -3 + 1
-= yes
+assert 16 == -5 * -3 + 1
```
# API