The following is the code.
\documentclass{article}
\usepackage{luacode}
\begin{document}
\luaexec{tex.sprint(string.format('\%.20f', math.pi))}
\end{document}
It gives the output as
3.14159265358979311600
It can easily be seen that the value of pi goes on incorrect. Compare here. The correct value up to 20 decimal places is
3.14159265358979323846
This has nothing to do with luaTeX or luacode because one gets same answer in lua. It has something to do how lua calculates value of pi. Is there a way to get correct value of pi in luaTeX or lua ?

eandpito a near-arbitrary number of decimal digits. – Mico Apr 23 '20 at 10:29