public boolean equals(Decimal other) { return comparesTo(other) == 0; }
public boolean isOne() { Decimal one = one(); return comparesTo(one) == 0; }
public boolean equals(Decimal value, Decimal maxDifference) { Decimal diff = this.subtract(value).absolute(); return diff.comparesTo(maxDifference) <= 0; }
public int asInteger() throws UcumException { if (!isWholeNumber()) throw new UcumException("Unable to represent "+toString()+" as an integer"); if (comparesTo(new Decimal(Integer.MIN_VALUE)) < 0) throw new UcumException("Unable to represent "+toString()+" as a signed 8 byte integer"); if (comparesTo(new Decimal(Integer.MAX_VALUE)) > 0) throw new UcumException("Unable to represent "+toString()+" as a signed 8 byte integer"); return Integer.parseInt(asDecimal()); }
public boolean equals(Decimal other) { return comparesTo(other) == 0; }
public boolean isOne() { Decimal one = one(); return comparesTo(one) == 0; }
public boolean equals(Decimal value, Decimal maxDifference) { Decimal diff = this.subtract(value).absolute(); return diff.comparesTo(maxDifference) <= 0; }
public int asInteger() throws UcumException { if (!isWholeNumber()) throw new UcumException("Unable to represent "+toString()+" as an integer"); if (comparesTo(new Decimal(Integer.MIN_VALUE)) < 0) throw new UcumException("Unable to represent "+toString()+" as a signed 8 byte integer"); if (comparesTo(new Decimal(Integer.MAX_VALUE)) > 0) throw new UcumException("Unable to represent "+toString()+" as a signed 8 byte integer"); return Integer.parseInt(asDecimal()); }