Skip to content

[regression] inconsistent signed int mod operator between runtime, compiletime, and semfold #12332

Closed
@jangko

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions