significandString property

String get significandString

Significand String

This method returns a string representing the "significand of this number" It is quite strange talking about a significand for an integer number. The meaning is, the digits that represent a number that can be multiplied for a power of ten to obtain the original number. For ex. 56 => 56. There is no difference between the number and the "significand" 200 = > 2 can be multiplied by 10^2 in order to obtain the original number. 0 => 0 At least one digit is required. Simplifying is the original number without the (exceeding) trailing zeros.

Implementation

String get significandString {
  if (this == BigInt.zero) {
    return '0';
  }
  var s = isNegative ? (-this).toString() : toString();
  var idx = s.length - 1;
  for (; idx > 0; idx--) {
    if (s[idx] != '0') {
      return s.substring(0, idx + 1);
    }
  }
  return s.substring(0, 1);
}