I plan to write a command which rounds a number with n digits. n is an optional argument and it is 2 by default. However, I keep receiving error message:
Missing number, treated as zero. Let's see if this prints: \round{3.1415926,2}
\documentclass{article}
\usepackage{tikz}
\newcommand{\round}[2][2]{\pgfmathparse{round({#1}*10^{#2})/(10^{#2})}\pgfmathresult}
\begin{document}
Let's see if this prints: \round{3.1415926,2}.
\end{document}
What have I done wrong? How to fix this code?
\round. It seems latex send the raw command to it rather than the result of the expression causing error. Is there any way to get around this problem? – ar2015 May 24 '18 at 02:44/pgf/number format/read comma as period=true|false, see section 92 of the pgfmanual. – May 24 '18 at 02:47