$ \left\lfloor 10^{\lfloor n \rfloor} \pi \bmod 10 \right\rfloor $ - does this function give the nth decimal place of pi?

69 Views Asked by At

Function to round the nth decimal place of pi to the nearest integer. For example, for pi, n = 0, y = 3. n = 1, y = 1. n = 2, y = 4. And so on and so forth.

Gives me good results until n = 17, which yields 8 instead of the expected 3. Then it's unfortunately kind of all over the place. It only gives me even numbers?

Is my function correct, or is this a Desmos error?

https://www.desmos.com/calculator/bekze2iayc

1

There are 1 best solutions below

0
On BEST ANSWER

Your function is mathematically correct, but not computerically correct. $64$ bit floating point numbers have about $16$ decimal digits of precision. You don't need the floor on $n$, but you are trying to extract decimal digits that are not there.