Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
> Having said that, do we still care about supporting other NBASE
> values? If NBASE == 10, the overflow case would have weight == 1 and
> digits[0] == 1, which would need to be treated differently.
There are already places that assume NBASE==10000. Still, I feel
that this is overthinking the problem. Jianqiao's solution is
obviously correct, and if you think maybe it isn't, changing the
"if" into a "while" would take care of any strange roundoff effects
in the second division.
regards, tom lane