Is double division equal to integer division if there is no remainder?

Viewed 915

On the JVM, does division between two double values always yield the same exact result as doing the integer division?

With the following prerequisites:

  • Division without remainder
  • No division by zero
  • Both x and y actually hold integer values.

E.g. in the following code

double x = ...;
int resultInt = ...;
double y = x * resultInt;
double resultDouble = y / x; // double division

does resultDouble always equal resultInt or could there be some loss of precision?

3 Answers
Related