| Ruud H.G. van Tol on Sat, 14 Dec 2024 12:07:36 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| digits of a float |
How to properly isolate a digit of a float? Example: ? my(n=19437); localprec(n+2); Pi *10^(n-1) \1 %10 %4 = 7 ? my(n=19437); localprec(n+3); Pi *10^(n-1) \1 %10 %5 = 6That type of code depends on the number of 9-digits in the decimal expansion of the value.
See also https://oeis.org/A000796, which uses localprec(n*6\5+29). What clean ways are there? -- Ruud