Library fixedpointarithmetic misses support for the neg function. Then the unary minus operator or \pgfmathneg truncate the result. The math expression "-0.123456789" is not longer equivalent to "0-0.123456789", because the latter subtraction is supported with full precision, whereas the former gets rounded to five digits. (Subtraction from zero can be used as workaround.)
Test file for reproducing the problem with suggestion to fix the issue:
% Setup
\input pgfmath
\input fp
\usepgflibrary{fixedpointarithmetic}
\pgfset{fixed point arithmetic}
% Test to show truncating function neg
\def\testnumber{.123456789}
\pgfmathneg{\testnumber}
\immediate\write16{neg(\testnumber) = \pgfmathresult}
% Fix suggestion
\catcode`\@=11
\def\pgfmathfpneg#1{%
\pgfmathfpparse{#1}%
\pgfmathfpneg@{\pgfmathresult}%
}
\def\pgfmathfpneg@#1{%
\begingroup
\FPneg\pgfmathresult{#1}%
\pgfmath@smuggleone\pgfmathresult
\endgroup
}
% Adding the line
% \let\pgfmathneg@=\pgfmathfpneg@
% to \pgfmathfp@parser@install
\expandafter\def\expandafter\pgfmathfp@parser@install\expandafter{%
\pgfmathfp@parser@install
\let\pgfmathneg@=\pgfmathfpneg@
}
% Test
\pgfset{fixed point arithmetic}
\pgfmathneg{\testnumber}
\immediate\write16{neg(\testnumber) = \pgfmathresult}
\csname @@end\endcsname\end
Assigning to Mark Wibrow.
Mark, my impression is that the fp library is somewhat discontinued in the sense that many of the available functions are missing here.
We could consider to eliminate it and finish the luamath library instead. Note that the luamath library is currently productive: whenever pgfplots runs a "plot expression", the parsing is done using the luamath library. It has exhaustive tests. However, "only" \pgfmathparse is supported and the documentation is missing entirely.
What do you think?
Thank you for reporting. This should be fixed now.