asInteger method
Implementation
int asInteger() {
if (!isWholeNumber()) {
throw UcumException('Unable to represent $this as an integer');
}
if (comparesTo(UcumDecimal.fromString(_int32MinValue.toString())) < 0) {
throw UcumException(
'Unable to represent $this as a signed 32-bit integer');
}
if (comparesTo(UcumDecimal.fromString(_int32MaxValue.toString())) > 0) {
throw UcumException(
'Unable to represent $this as a signed 32-bit integer');
}
return int.parse(asUcumDecimal());
}