Skip to content

wrong modulo computation for negative doubles or floats #58

Description

@rschumi0

There seems to be an issue with the modulo operator. The computation is wrong for all negative doubles and floats, i.e. it produces inconsistent values compared to Java and also compared to the same computation with Integer values. This is illustrated in the following examples.

System.out.println("-8 % 3 = "+(-8 % 3)); //both kjava and java return -2
System.out.println("-8.0 % 3.0 = "+(-8.0 % 3)); //kjava: 1.0 java: -2.0
System.out.println("8 % -3 = "+(8 % -3 )); // both return 2
System.out.println("8.0 % -3.0 = "+(8.0 % -3.0)); //kjava: -4.0 java: 2.0

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions