On Sun, 03 Dec 2017 12:25:15 +0000, Philippe Meunier wrote:
> kshe wrote:
> >Also, the manual defines the length of a number as its number of digits,
> >so perhaps it should be precised that zero is considered to have no
> >digits, which might not be obvious to everyone.
>
> Am I the only who thinks this is not just not obvious, but actually wrong?
If the number `002' is said to have only one digit because the zeros in
the left are not significant, then likewise the number `000', which
hence only has insignificant digits, can in perfect coherence be
considered to have no digits at all.
Another way to see why this makes sense is by defining the number of
digits in base b of an integer n by
intlog_b(n) + 1 := floor(log_b(n)) + 1
and noticing that the very natural recursive expression of such integer
logarithm
intlog_b(n+1) = | intlog_b(n) + 1 if n+1 is a power of b
| intlog_b(n) otherwise
can be made to hold for n = 0 if and only if one sets intlog_b(0) = -1
by convention, which indeed leads to the conclusion that zero must have
zero digits as per the definition above. Any other convention for the
value of intlog_b(0) would not preserve this fundamental invariant of
the integer logarithm, thus being nothing but arbitrary, and as such of
little practical value.
Regards,
kshe