If two double values(a and b) which
- both are not negative
- both are not an
NaNnor any(POSITIVE|NEGATIVE)_INFINITY, - a >= b
Is it always true that
- Double.doubleToLongBits(a) >= Double.doubleToLongBits(b)
?
Is there any possible false per IEEE 754 stuff?
I’m intending to store a rate value for two positive (non-zero) integers as a long value not as a double value.
@Entity
public class ExchangeRate {
@PrePersist
protected void prePersist() {
targetAmountPerSourceAmount = Double.doubleToLongBits(
(double) targetAmount / (double) sourceAmount);
}
@Basic
private long targetAmountPerSourceAmount;
@Min(1)
@Max(Short.MAX_VALUE)
private short targetAmount;
@Min(1)
@Max(Short.MAX_VALUE)
private short sourceAmount;
}
Well, zeros are going to cause you a problem, since +0.0 == -0.0 but they have different representations.