Confusion about natural numbers and leading zero(s)

1.1k Views Asked by At

Let x be a natural number and R(x) be the reversal of x.

  • If R(x)=2000, then what is x ?
  • If R(x)= 2000000, then what is x?

I feel it's strange if they both have the same answers x=2. If they both have the same answers x=2, then we can state that There are no natural numbers whose reversal ending with digit zero???. My question is: Are $2$, $02$, $002$, $0002$ the same numbers or they are $4$ distinct numbers with the same absolute value 2 ?

List item

2

There are 2 best solutions below

2
On

For a natural number there is no such thing as a leading or ending digit. However, for the representation of that number in a (positional) number system such as the decimal system, we can speak of leading/ending digits. It is customary to not write leading zeroes (except for the number zero itself that has the decimal representation $0$ consisting of a single digit symbol that is both leading and ending). Hence the number of fingers on my hands combined is written as $10$, not $010$, not $0010$. In this sense, $02$, $002$, $0002$ are not valid representations of natural numbers in the decimal (or any other positional) system.

It also follows from this that when one wants o define a function $R$ for the concept "reversal of digits" one has to either make the convention that the result is not defined for numbers that "illegally" produce a representation that would begin with digit $0$ (without being the representation of $0$ itself); or to make the convention that any superfluous leading zeroes produced by reversal are to be dropped. The first convention would make $R(20)$ and $R(200)$ undefined; the second makes $R(20)=R(200)=2$. With both of these conventions, there is no natural number $n$ with $R(n)=20$.

0
On

You are porposing an exoctic function R(x) that is not a classical function of Naturals (ℕ), it is an algorithm to play with strings obtained from specific Natural Number repreentation. You used the base10 (decimal) representation in your examples, but binary, base4, base16, etc. will offer diferent results.

Let's try to make some practical assumptions:

  1. We can adopt base2 (or "bit string") as the canonical representation.

  2. Interpret the leading zeros as a valid representation... But there are two very distinct ways to do so:
    restricting the to a fixed number of bits (e. g. 64 bits unsigned integer representations), all interpreted in usual positional representation; or
    free variable length number of bits (e. g. bitstring from 1 to 64 bits).

Leading zeros in a fixed-length unsigned integer

There are no problem on revert bit-order (or negate all bits): the result is in the same set (domain), it is a legitimate inverse function, $R(x)$ and $R^{-1}(x)$ exist.

Leading zeros in a variable-length bitstring

Now the set have more elements: a set of all codes of maximal length m is a set of bitstrings with maximal bit-length m.

We can use the leading zeros to preserve information of a "numeric code" like 007 of James Bond or 000abc123 of an Geohash... But when we do it, we must to consider the "set of codes", that is a superset of numerical and non-numerical representations.

Now we can say, using the canonical representation, that all codes are into a finite set C of codes, and that only elements of the subset L of "leading zero codes" are non-numeric, all other elements are Natural Numbers (a finite subset N of ℕ)... So    C = LN.

Now there are a valid domain and a codomain for your "reverse code" function:

$$R\colon C\rightarrow C$$

NOTES. A little bit more (secondary) discussion.

Now, with a context and better definitions, we can talk about R(ℕ), or better, about finite R(N⊂ℕ), so about the validity or existence of a function $R\colon N\rightarrow N$. Now we can proof that it not exist, and, for a variant that exists, check when it is an inversible function.

The function R is an algorithm where all inputs are Naturals but not all outputs will be into N, some of them will be into the set L.

The function R(N) can't be an injective function. The only valid definition is $R\colon N\rightarrow C$, but it is not inversible (as you solicitated). The only way to obtain $R$ and somothing as $R^{-1}$ (and suppose $R=R^{-1}$) is using the same superset C as domain and codomain, therefore you must use $R\colon C\rightarrow C$.