2 つの double 値 (a と b) の場合
- どちらもマイナスではない
- 両方とも、
NaN
またはいずれでもない(POSITIVE|NEGATIVE)_INFINITY
、 - a >= b
それは常に本当ですか
- Double.doubleToLongBits(a) >= Double.doubleToLongBits(b)
?
IEEE 754 のものごとに false の可能性はありますか?
double 値ではなく long 値として、2 つの正 (ゼロ以外) の整数のレート値を格納するつもりです。
@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;
}