Floating point arithmetics restricted to integers
Posted
by
user396672
on Stack Overflow
See other posts from Stack Overflow
or by user396672
Published on 2010-12-28T12:00:12Z
Indexed on
2010/12/28
13:54 UTC
Read the original article
Hit count: 167
java
|floating-point
I use doubles for a uniform implementation of some arithmetic calculations. These calculations may be actually applied to integers too, but there are no C++-like templates in Java and I don't want to duplicate the implementation code, so I simply use "double" version for ints.
Does JVM spec guarantees the correctness of integer operations such a <=,>=, +, -, *, and / (in case of remainder==0) when the operations are emulated as corresponding floating point ops?
(Any integer, of course, has reasonable size to be represented in double's mantissa)
© Stack Overflow or respective owner