In your case the calculation of cos(5*pi/3)
is done with higher precision, but the choice of trunc
is worse than round
:
\documentclass[preview,border=12pt]{standalone}
\usepackage[nomessages]{fp}
\FPeval\Sixty{trunc(cos(pi/3):12)}
\FPeval\ThreeHundredTrunc{trunc(cos(5*pi/3):12)}
\FPeval\ThreeHundredRound{round(cos(5*pi/3):12)}
\FPeval\Tmp{cos(5*pi/3)}
\FPeval\TruncDelta{\Tmp-\ThreeHundredTrunc}
\FPeval\RoundDelta{\Tmp-\ThreeHundredRound}
\usepackage{amsmath}
\begin{document}
$\!
\begin{aligned}
\cos 60^\circ &= \Sixty\\
\cos 300^\circ &= \ThreeHundredTrunc~\text{(trunc)}
& \Delta &= +\TruncDelta\\
\cos 300^\circ &= \ThreeHundredRound~\text{(round)}
& \Delta &= \RoundDelta
\end{aligned}
$
\end{document}

In this case the final error of the calculation using trunc
is 999999 times greater than the variant using round
.
Float arithmetic with decimal (or binary) numbers has its limitations, because
already rational numbers cannot be expressed with a finite number of digits
in the decimal (or binary) system. The typical workaround is using a higher precision in the internal representation and rounding the result. Using truncating makes it worse.
\fp_eval:n
returns 0.5000000000000001 for both. Does really a difference in the 12th decimal digit bother you?