[Tex/LaTex] Why is there a decimal for 3×4=12.0

pgfmath

Why does \pgfmathresult display the result of 3×4 as 12.0?

\documentclass{article}

\usepackage{pgf}

\begin{document}

\pgfmathparse{3*4}
\pgfmathresult

\end{document}

This code yields a document whose sole contents is "12.0".

In some parts of the document I'm working on, I'll need decimal places, but not for grade 2 math.

How do I fix this?

Best Answer

First, you are not formatting the number when you say \pgfmathresult. Second, you have not specified any particular format for number printing. (Although the default format will do, in this case.)

Compare:

\documentclass{article}
\usepackage{pgf}
\begin{document}

\pgfmathparse{3*4}
\pgfmathresult

\pgfmathprintnumber\pgfmathresult

\pgfmathparse{int(3*4)}
\pgfmathresult

\pgfkeys{% just for example - doesn't actually matter here
  /pgf/number format/int detect,
}

\pgfmathparse{3*4}
\pgfmathprintnumber\pgfmathresult


\end{document}

comparison

PGF doesn't know you are typesetting Grade 2 maths rather than a doctoral dissertation in nuclear engineering!