[Tex/LaTex] Omit zeros before the decimal point and convert scientific notation in siunitx/pgfmath

formattingpgfmathsiunitx

I'm trying to automatically format numbers in a way that doesn't convert say .8 to 0.8 while at the same time scientific notation is converted to exponent-free notation. siunitx seems to be able to do both but I don't get it to work together.

\documentclass{article}
\usepackage{siunitx}
\newcommand{\myround}[1]{\num[zero-decimal-to-integer,scientific-notation=fixed,fixed-exponent=0,round-mode=places,round-precision=2,add-integer-zero=false]{#1}}
%\newcommand{\myround}[1]{\num[zero-decimal-to-integer,round-mode=places,round-precision=2,add-integer-zero=false]{#1}}
\pagestyle{empty}
\begin{document}
\myround{.8}
\myround{1}
\myround{4.00000000001}
\myround{-.1151}
\myround{4.44089209850063E-16}

.80
1
4
-.12
0
\end{document}

The first \newcommand in this MWE IMHO should produce the right result because it got all the right options. However, the zeros before the decimal point are added back in:

zeros still there

Using the second macro definition (that is commented out) yields this result, proving that in principle it should work but of course the scientific notation isn't converted and not rounded properly either (rounding to two decimal places, 4.44×10-16 should be 0.00×100 if anything).

scientific notation still there

I also added the pgfmath tag because \pgfmathprintnumber seems to have much of the same options as \num from siunitx and I don't know if one uses the other internally and I also wouldn't mind to use that other if it does what I need.

Best Answer

\pgfmathprintnumber can do this if you specify skip 0. and fixed:

\documentclass{article}
\usepackage{tikz}
\newcommand{\myround}[1]{\pgfmathprintnumber[skip 0.,fixed]{#1}}
\pagestyle{empty}
\begin{document}
\myround{.8}
\myround{1}
\myround{4.00000000001}
\myround{-.1151}
\myround{4.44089209850063E-16}

.80
1
4
-.12
0
\end{document}