3

I need some calculations with fpeval, where I want numbers like '21' outwritten as '21.0' with one zero after the point.

Is this possible at xfp.sty?

enter image description here

\documentclass[margin=5pt, varwidth]{standalone}
\usepackage{xfp}
\begin{document}
good: \fpeval{round(1.234,2)}

good too: \fpeval{round(2.34,2)}

not good: \fpeval{round(21,2)}; wanted: 21.0 (with \emph{one} (1) zero in that integer case) \end{document}

cis
  • 8,073
  • 1
  • 16
  • 45

1 Answers1

4

xfp is for calculations. For pretty printing the numbers use siunitx:

\documentclass[margin=5pt, varwidth]{standalone}
\usepackage{xfp,siunitx}
\begin{document}
\num[minimum-decimal-digits=1]{\fpeval{round(21,2)}}; 
wanted: 21.0  (with \emph{one} (1) zero in that integer case)
\end{document}

enter image description here

Ulrike Fischer
  • 327,261