1

I creat me a newcommand that use calculator packages. It is for a cross-multiplication, basically to pass units.

The newcommand say:

\newcommand{\regladetres}[6]{\MULTIPLY{#5}{#3}{\numerador}\DIVIDE{\numerador}{#1}{\resultado}\ROUND[2]{\resultado}{\resultado}\begin{align*}
        \SI{#1}{#2} & \text{\line(1,0){40}}\SI{#3}{#4}\\
        \SI{#5}{#6} & \text{\line(1,0){40}}x=\frac{\SI{#5}{\cancel#6}\cdot\SI{#3}{#4}}{\SI{#1}{\cancel#2}}=\SI{\resultado}{#4}
    \end{align*}
}

work fine when the numbers are minor that 15999, but when multiply 15999x15999 fail or when the numbers (any) mayor that 15999.

How can I do to use great number? In the deep, not more great only 101325. The problem I think that not is siunitx package, because I use bigger numbers without problem.

Thanks a lot!

Darío

1
  • you can use \fpeval: \qty{\fpeval{159999*159999}}{Hz}. Commented Apr 1, 2023 at 20:52

2 Answers 2

1

First: the \SI macro in siunitx is obsolete and should be replaced with \qty.

Second, for such a use case you should probably use the LuaLaTeX compiler, so that you can make the computations in Lua and have them printed in LaTeX.

\documentclass{article}
\usepackage{luacode}
\usepackage{siunitx}

\directlua{
    a = 15999
    b = 15999
    c = 1e8
    d = 3.4e12
}

\begin{document}
First ratio : \qty{\directlua{tex.print(a/b)}}{m}

Second ratio : \qty{\directlua{tex.print(c/d)}}{Hz}
\end{document}

result

As you can see, everything you type in the \directlua macro is Lua code. Then, inside the Lua code, the tex.print function sends the value of its argument to LaTeX.

Also, if you have several \directlua macros, they are treated as part of the same block of code, so you can reuse variables from one to the other.

If you want to format the numbers, you can do it in Lua using the usual string-formatting functions before sending them back to LaTeX.

0

Well, the problem not is a problem. The calculator package can not operate with numbers more bigs that 2^14. The documentation, section 13.1 say thus:

The largest TeX number is 16383.99998 ≈ 214 ; \cctr@logmaxnum is the logarithm of this num-
ber, 9.704 ≈ log 16384.

Meanwhile I wait for the new Debian's upgrade for use the new packages. Because somethings like nicematrix and siunitx are old (2020).

Thanks a lot!

You must log in to answer this question.

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