You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ FixedDecimal{Int64,1}(0.3)
47
47
48
48
### Arithmetic details: Overflow and checked math
49
49
50
-
By default, all arithmetic operations on FixedDecimals**will silently overflow**, following the standard behavior for bit integer types in Julia. For example:
50
+
By default, all arithmetic operations on FixedDecimals, except division, **will silently overflow** following the standard behavior for bit integer types in Julia. For example:
@@ -59,6 +59,8 @@ julia> abs(FixedDecimal{Int8,2}(-1.28)) # negative typemin wraps to typemin aga
59
59
FixedDecimal{Int8,2}(-1.28)
60
60
```
61
61
62
+
*Note that **division** on FixedDecimals will throw OverflowErrors on overflow, and will not wrap. This decision may be reevaluated in a future breaking version change release of FixedDecimals. Please keep this in mind.*
63
+
62
64
In most applications dealing with `FixedDecimals`, you will likely want to use the **checked arithmetic** operations instead. These operations will _throw an OverflowError_ on overflow or underflow, rather than silently wrapping. For example:
ERROR: OverflowError:1.00÷0.50 overflowed for type FixedDecimal{Int8, 2}
72
74
```
73
75
74
-
**Checked division:** Note that `checked_div` performs truncating, integer division. Julia Base does not provide a function to perform checked decimal division, so we provide one in this package, `FixedPointDecimals.checked_decimal_division`.
76
+
**Checked division:** Note that `checked_div` performs truncating, integer division. Julia Base does not provide a function to perform checked *decimal* division (`/`), so we provide one in this package, `FixedPointDecimals.checked_rdiv`. However, as noted above, the default division arithmetic operators will throw on overflow anyway.
75
77
76
78
Here are all the checked arithmetic operations supported by `FixedDecimal`s:
0 commit comments