Finding the value of a given digit placement in a number

I made a function that can find the value of a given digit placement in a number. For example, if I had pi as my number and plug it into the function with the digit 6, it would output 9, since 9 is the 6th digit of pi. the equation looks like this: f_{getvalue}\left(N,D\right)=\operatorname{mod}\left(\operatorname{floor}\left(N\cdot10^{\left(D-\operatorname{floor}\left(\log\left(N\right)+1\right)\right)}\right),10\right)
the variable N means the number, and D means the digit you want. For some reason, it only works up to the 20th digit. Why does it break and how do I fix it?

This forum is more intended for teachers using the Activity Builder, and not so much for graphing calculator issues. I know there’s a reddit for desmos you might find useful. To answer your question though, it’s likely something to do with the way desmos actually calculates larger exponential values.