I can calculate the number of digits in $x$:
$$M=\Big\lfloor\log_{10}{x}\Big\rfloor+1$$
And then calculate the first $N$ digits in $x$:
$$\Big\lfloor\frac{x}{10^{M-N}}\Big\rfloor$$
Is there any trick to achieve that without counting the number of digits in $x$ to begin with?
$x = 12345678$
$y = log_{10}(x)$
$z = \left\lfloor y \right\rfloor$
$t=y-z$
$u= 10^t$
And then work with $u$