6

How can I change the number of digits in the scientific notation?

\documentclass{article}
\usepackage{xparse,siunitx}

\begin{document}

\ExplSyntaxOn
\num{\fp_to_scientific:n { 3785*23 } }
\ExplSyntaxOff

\end{document}
  • 2
    How do you want it to be changed? – egreg Dec 8 '17 at 21:36
  • In most cases less than 16 digits, for example only 2 digits – user139826 Dec 8 '17 at 21:37
  • 2
    Isn't this the job of \num rather then? – user31729 Dec 8 '17 at 21:37
8

I guess you want

\documentclass{article}
\usepackage{siunitx,xfp}

\begin{document}

\num[scientific-notation=true]{\fpeval{3785*23}}

\end{document}

enter image description here

More examples:

\documentclass{article}
\usepackage{siunitx,xfp}

\begin{document}

\num[scientific-notation=true]{\fpeval{3785*23}}

\num[scientific-notation=true,round-mode=figures]{\fpeval{3785*23}}

\num[scientific-notation=true,round-mode=figures,round-precision=3]{\fpeval{3785*23}}

\end{document}

enter image description here

  • yes thats right. – user139826 Dec 8 '17 at 21:43
4

Here's a solution that combines \num from the siunitx package with LuaLaTeX.

enter image description here

\documentclass{article}
\usepackage{siunitx}
\newcommand\myeval[1]{\directlua{tex.sprint(#1)}}

\begin{document}
\num[scientific-notation=true]{ \myeval{3785*23} } 
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy