Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong modulo computation for negative doubles or floats #58

Open
rschumi0 opened this issue Feb 29, 2020 · 0 comments
Open

wrong modulo computation for negative doubles or floats #58

rschumi0 opened this issue Feb 29, 2020 · 0 comments

Comments

@rschumi0
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant