Closed
Description
With the introduction of Int128 inside Nim compiler, it also introduce this regression.
Example
let ma = -100'i64
let mb = 13
let rtmod = ma mod mb
const ctmod = -100'i64 mod 13
debugEcho "SF MOD: ", -100'i64 mod 13 # semfold `mod`
debugEcho "RT MOD: ", rtmod
debugEcho "CT MOD: ", ctmod
Current Output
SF MOD: 9
RT MOD: -9
CT MOD: 9
Expected Output
SF MOD: -9
RT MOD: -9
CT MOD: -9
Possible Solution
The Int128 mod
operator assigns wrong sign to the remainder based on divisor sign and not based on dividend sign.
Additional Information
$ nim -v
Nim Compiler Version 1.0.99 [Windows: amd64]
Compiled at 2019-10-02
Copyright (c) 2006-2019 by Andreas Rumpf
git hash: c20778d2d3faa1ad1e9b11a54899b5eef5ac6bca
active boot switches: -d:release
Activity