The MWE below suggests that truncating an fp type number is not just for cosmetics but actually changes the number's value. Is there a way to reduce the number of decimals displayed without affecting the number's full accuracy in computations? I browsed through siunitx but nothing jumped at me.

% RN. 6 April 2017
%  Truncating floating point numbers 
    \fp_eval:n {trunc(#2,#1)*trunc(#3,#1)}
  }  %  \myTruncatingFloatingPoints

    1. Full complement of digits:~\myTruncatingFloatingPoints{5}

    2. Truncated to 2 decimal digits:~  \myTruncatingFloatingPoints{2}
  • 1
    Why not use a second variable? Assign the value of the first to the second and truncate that one for printing. This way you can calculate with the first one with full accuracy. (might be an ugly workaround)
    – Skillmon
    Apr 6, 2017 at 9:41

3 Answers 3


Taken from How to set the precision in numbers (there are more versions, have a look):



Is that what you are looking for?


Here I use \num just for pretty printing.



No truncation  & \num{\fpeval{3.11998*3.0198}} \\
Truncation     & \num{\fpeval{trunc(3.11998*3.0198,2)}} \\
Bad truncation & \num{\fpeval{trunc(3.11998,2)*trunc(3.0198,2)}}


enter image description here

  • Truncating the result only is the obvious thing to do, except that I wanted truncated versions of the operands, say for instance as elements of a matrix, then do operations with full accuracy ... Anyway, we have had answers. Apr 6, 2017 at 22:37
  • 1
    @ReinhardNeuwirth I'm afraid I don't understand; computations are distinct from printing the result.
    – egreg
    Apr 6, 2017 at 22:57
  • You are quite right! It seems I got myself into a muddle here. Apr 7, 2017 at 9:32

Because I felt like reinventing the wheel...(again)

EDITED so that truncating to 0 places does not present the decimal.

RE-EDITED to handle negative numbers.

    \ifnum#3<5\relax#2\else\the\numexpr#2+1\relax\fi% ROUNDED
%    #2% TRUNCATED
  \fi%%  \fi%
1. \makebox[.8in][r]{9.421715604} to 5 digits: \myTruncatingFloatingPoints{5}{9.421715604}

2. \makebox[.8in][r]{9.421715604} to 3 digits: \myTruncatingFloatingPoints{3}{9.421715604}

3. \makebox[.8in][r]{9.421715604} to 1 digits: \myTruncatingFloatingPoints{1}{9.421715604}

4. \makebox[.8in][r]{9.421715604} to 0 digits: \myTruncatingFloatingPoints{0}{9.421715604}

5. \makebox[.8in][r]{29} to 2 digits: \myTruncatingFloatingPoints{2}{29}

6. \makebox[.8in][r]{.1275} to 3 digits: \myTruncatingFloatingPoints{3}{.1275}

7. \makebox[.8in][r]{.1275} to 4 digits: \myTruncatingFloatingPoints{4}{.1275}

8. \makebox[.8in][r]{$-$.12} to 6 digits: \myTruncatingFloatingPoints{6}{-.12}

enter image description here

  • Truncated to 0 shouldn't have the decimal point.
    – Tim
    Apr 6, 2017 at 13:24
  • @Tim Done, per your suggestion. Apr 6, 2017 at 14:44

You must log in to answer this question.

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