Skip to content

Commit b3121b1

Browse files
vk2sebzyp
authored andcommitted
fixed.Value: add truncate() method, document rounding strategy
1 parent cd8c9bc commit b3121b1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

text/0041-fixed-point.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ The following operations are defined on it:
6060
- If `value` is an `int` or `float`, it'll be cast to a `fixed.Const` first.
6161
- If `value` is a `fixed.Value`, the precision will be extended or rounded as required.
6262
- `.round(f_bits=0)`: Return a new `fixed.Value` with precision changed to `f_bits`, rounding as required.
63+
- Rounding strategy: round to nearest with ties rounded towards positive infinity.
64+
- Under the hood, this involves truncating and adding the most significant truncated bit.
65+
- `.truncate(f_bits=0)`: Return a new `fixed.Value` with precision changed to `f_bits`, truncating as required.
6366
- `.__add__(other)`, `.__radd__(other)`, `.__sub__(other)`, `.__rsub__(other)`, `.__mul__(other)`, `.__rmul__(other)`: Binary arithmetic operators.
6467
- If `other` is a `Value`, it'll be cast to a `fixed.Value` first.
6568
- If `other` is an `int`, it'll be cast to a `fixed.Const` first.

0 commit comments

Comments
 (0)