How to find out if a number is a hundred or thousand? The question might raise people's eyebrows but I have been googling and I don't know the keyword to search for. I just don't know the mathematical term.
What I'm trying to do is I want to round a number to the left most significant figure. 
For example, 

If I have $1111$ I want to round it to $1000$
  If I have $423$ I want to round it to $400$.

I figured out a way to do this. If somebody can confirm if I'm close to being correct, I would be very grateful.
for $423$ I would do Math.floor(423/100) * 100 but in order to do that I would have to know for each number what to divide and multiply. 
What I don't want to do is a bunch of if-else blocks like this.
if number is > 10 and number is < 99 then:
  divide by 100
else if number is > 99 and number is < 999 then:
  divide by 1000
// so on

 A: Say $n$ is your number, then


*

*the largest order of the power of $10$ smaller than $n$ is $\lfloor\log_{10} n\rfloor$ (i.e. the largest integer $d$ s.t. $10^d\leq n$

*the greatest power of $10$ smaller than $n$ is hence $10^{\lfloor\log_{10} n\rfloor}$

*the most significant digit is $\left\lfloor\frac{n}{10^{\lfloor\log_{10} n\rfloor}}\right\rfloor$


Therefore, what you look for can be computed as
$$
\left\lfloor\frac{n}{10^{\lfloor\log_{10} n\rfloor}}\right\rfloor
\cdot
10^{\lfloor\ln_{10} n\rfloor}
$$
I would then insert an if statement beforehand just to rule out the case $n=0$.
A pseudocode would look like (I extended it for negative numbers using the absolute value abs and sign sign functions)

if n == 0, then
  $~~~~$return 0
end if
d = floor(log(abs(n)) / log(10)) $\color{green}{\%~~\text{NB: }{\tt d}\text{ is to be converted to integer type}}$
return sign(n) * floor(abs(n)/10^d) * 10^d

Notice that this works also for decimal numbers smaller than $1$:
e.g. for $n=0.024$ it would return $0.02$.
If this is not the wanted behaviour, edit the first if statement accordingly.
A: You could convert the number to a string and take its length to know what power of 10 to use for the rounding for one idea.
Alternatively, you could try to put the number into scientific notation and round the value that way for another option if you're OK with floating point numbers being used.
Base 10 Logarithms would also be another idea here that can work as noted in the comments.
