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}
1

1 Answer 1

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

3
  • 1
    Strange: yields "! Package siunitx Error: Unknown option 'minimum-decimal-digits'."
    – cis
    May 31, 2021 at 18:26
  • then you have an older siunitx. Check its docu how the option was named there. May 31, 2021 at 18:30
  • Looks like round-minimum, round-mode (can take value (off, figures, places)) and round-precision. (documentation for version 2.7n, other versions
    – user202729
    Dec 15, 2021 at 1:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .