Let's say I've got two integer values stored in double
variables, e. g.:
double x = 100.0;
double y = 7.0;
May I safely assume that any arithmetic operation on these two double variables that would yield an integer result, will return an exact integer value (as a double
)? That is, will for example all of:
x + y = 107.0
x - y = 93.0
x * y = 700.0
return the exact integer values, or will be there some accuracy problems? Like x*y
being 699.99995
or so?
The general question: Is it true that any arithmetic operation on two double variables holding integer values that would yield an integer result will return the exact integer value (as a double)?
I'm asking this in a Java context, but I assume it's similar in other languages, too.