Skip to content

Change mod for Int #161

@Thimoteus

Description

@Thimoteus

For example, -3 mod 9 should be 6 (since 6 - 9 = -3) but in PS we have mod (-3) 9 == (-3), which ultimately stems from JS's -3 % 9 === -3

Some people suggest using the following FFI:

function mod(n, m) = {
  return ((n % m) + m) % m;
}

References:
http://www.seqmedia.com/2011/03/16/javascript-negative-numbers-modulus-bug/
https://stackoverflow.com/questions/4467539/javascript-modulo-gives-a-negative-result-for-negative-numbers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions