Let $b$ be a base, that is, an integer greater than or equal to $2$, and let $n$ be a positive integer that has $d$ digits in base $b$. What is the formal definition of the function that takes a positive integer $m$ less than or equal to $d$, and outputs the $m$-th digit of $n$, starting from the left? I know what it is, intuitively, but I want a formal definition.
Formal definition of $m$-th digit of positive integer
68 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 2 best solutions below
On
It's well established that for any natural $n$ and any natural base $b$ there are a distinct set of digits so that $n$ may be express with those digits base $b$.
So to say let $f(m)$ be the $m$th digit from the left is perfectly well-defined. What makes it informal is the "from the left".
As you are assuming that the number of digits, $d$, is known though we can formally state this as the digit coefficient for $b^{d-m}$.
If that feels to obfuscated we can be a bit more explanatory and state that $f(m) = a_{d-m}$ where $a_0, ...., a_{d-1}$ are the unique digits $a_k\in \mathbb N; a_k < b$ where $n = \sum_{k=0}^{d-1}a_k b^k$.
If you want something more calculatory ... well, Robert Shore really has a good answer to that. $f=\lfloor \frac n{b^{d-m}}\rfloor \% b$ where $\lfloor \rfloor$ is the floor (greatest integer) function and $\%$ is the remainder operator.
$\displaystyle f(n, m)=\left \lfloor \frac{n}{b^{d-m}} \right \rfloor \bmod b$