setScale method

LexoDecimal setScale(
  1. int nsig, [
  2. bool ceiling = false
])

Implementation

LexoDecimal setScale(int nsig, [bool ceiling = false]) {
  if (nsig >= sig) {
    return this;
  }
  if (nsig < 0) {
    nsig = 0;
  }
  final diff = sig - nsig;
  var nmag = mag.shiftRight(diff);
  if (ceiling) {
    nmag = nmag.add(LexoInteger.one(nmag.getSystem()));
  }
  return LexoDecimal.make(nmag, nsig);
}