Getting precision of integer given a float precision point

35 Views Asked by At

Let's say I have the number 1234567 and I want to get the value 12.34567 with a precision point of 0.01. How would I go about doing this?

If I multiply the precision point and the number, I end up with 12345.67 which is the opposite of what I need and I am unsure how to approach this. Thanks in advance.

1

There are 1 best solutions below

0
On

Dividing the number by $10^{\lfloor\log n\rfloor}$ shifts the decimal point to just after the first digit, and then you can further shift the decimal point relative to that number.


$$ \log n - 1 < \lfloor\log n\rfloor \le \log n\\ 10^{\log n-1} < 10^{\lfloor\log n\rfloor} \le 10^{\log n}\\ \frac n{10} < 10^{\lfloor\log n\rfloor} \le n\\ \frac{n}{n/10} > \frac n{10^{\lfloor\log n\rfloor}} \ge \frac nn\\ 10 > \frac n{10^{\lfloor\log n\rfloor}} \ge 1\\ $$