comparesTo method
Implementation
int comparesTo(UcumDecimal? other) {
if (other == null) {
return 0;
} else {
if (negative && !other.negative) {
return -1;
} else if (!negative && other.negative) {
return 1;
} else {
final int maxUcumDecimal = math.max(decimal, other.decimal);
String s1 = ('0' * (maxUcumDecimal - decimal + 1)) + digits;
String s2 = ('0' * (maxUcumDecimal - other.decimal + 1)) + other.digits;
if (s1.length < s2.length) {
s1 = s1 + stringMultiply('0', s2.length - s1.length);
} else if (s2.length < s1.length) {
s2 = s2 + stringMultiply('0', s1.length - s2.length);
}
int result = s1.compareTo(s2);
if (negative) {
result = -result;
}
return result;
}
}
}