mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
crash on rem div by zero
This commit is contained in:
parent
dd86b11150
commit
b3dfdb562b
88 changed files with 554 additions and 534 deletions
|
@ -1031,13 +1031,21 @@ divTruncUnchecked : Int a, Int a -> Int a
|
|||
## Num.rem -8 -3
|
||||
## ```
|
||||
rem : Int a, Int a -> Int a
|
||||
rem = \a, b ->
|
||||
if Num.isZero b then
|
||||
crash "Integer division by 0!"
|
||||
else
|
||||
Num.remUnchecked a b
|
||||
|
||||
remChecked : Int a, Int a -> Result (Int a) [DivByZero]
|
||||
remChecked = \a, b ->
|
||||
if Num.isZero b then
|
||||
Err DivByZero
|
||||
else
|
||||
Ok (Num.rem a b)
|
||||
Ok (Num.remUnchecked a b)
|
||||
|
||||
## traps (hardware fault) when given zero as the second argument.
|
||||
remUnchecked : Int a, Int a -> Int a
|
||||
|
||||
isMultipleOf : Int a, Int a -> Bool
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue