setValueUcumDecimal method
void
setValueUcumDecimal(
- String value
)
Implementation
void setValueUcumDecimal(String value) {
scientific = false;
negative = value.startsWith('-');
if (negative) {
value = value.substring(1);
}
while (value.startsWith('0') && value.length > 1) {
value = value.substring(1);
}
final int dec = value.indexOf('.');
if (dec == -1) {
precision = value.length;
decimal = value.length;
digits = value;
} else if (dec == value.length - 1) {
throw UcumException("'$value' is not a valid decimal");
} else {
decimal = dec;
if (allZeros(value, 1)) {
precision = value.length - 1;
} else {
precision = countSignificants(value);
}
digits = delete(value, decimal, 1);
if (allZeros(digits)) {
precision = precision + 1;
}
while (digits.startsWith('0')) {
digits = digits.substring(1);
decimal--;
}
}
}