-
Notifications
You must be signed in to change notification settings - Fork 26
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
Review correctness of integer division in floating point context #479
Comments
This was an extremely fun bug to verify since it's nature was mathematical, I also got a chance to use the Wolfram-Alpha-Calculator which is a fun-tool like |
Although, I suggest I should come up with a pull-request to define the test-group: |
Ok, I just took a look at this. This is interesting: public static void main(String[] argv) {
int a = -902342342;
int b = 3233337;
int intDivision = a / b;
double floor = Math.floor(a / b);
double floorDiv = Math.floorDiv(a, b);
double casted = (double)a / (double)b;
double floorCasted = Math.floor(casted);
System.out.printf("a / b as int = %d\n", intDivision);
System.out.printf("floor(a / b) as double = %f\n", floor);
System.out.printf("floorDiv(a / b) as double = %f\n", floorDiv);
System.out.printf("floor((double)a / (double)b) as double = %f\n", floorCasted);
} Output:
All three values are the same if What are your thoughts? |
I agree, Also within this code |
Fixed by Pull-Request:#500 . |
See:
AesCbcCipherDetails.java:124
The text was updated successfully, but these errors were encountered: