0

i would like to use the \CUBE function from calculator package, but it does not work with numbers greater than 25

\documentclass[10pt,a4paper]{article}
\usepackage{relsize,amsmath}
\usepackage{calculator}
%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%
\CUBE{5}{\sol}
\sol\\
\CUBE{15}{\sol2}
\sol2\\
\CUBE{25}{\sol3}
\sol3\\
\CUBE{26}{\sol4}
\sol4\\
\end{document}

i get the the error message:

! Dimension too large.
<recently read> \cctr@lengtha 
                              
l.16 \CUBE{26}{\sol4}
                     
? 

Is there any help?

1
  • Please note that \sol2 is no valid macro name (as well as \sol3 and \sol4). Macro names can't contain numbers if LaTeX's standard category codes apply.
    – Skillmon
    Nov 12, 2020 at 14:53

2 Answers 2

2

LaTeX3 contains a floating point library which allows much bigger numbers than calculator. You can use it by using \usepackage{xfp}:

\documentclass[]{article}

\usepackage[]{xfp}

\newcommand\CUBE[1]{\fpeval{(#1)^3}}

\begin{document}
\CUBE{5}

\CUBE{15}

\CUBE{25}

\CUBE{35}
\end{document}
10
  • @AAA no, calculator uses dimens for its calculations and so it can't handle large numbers. Why don't you want to use xfp? Nov 12, 2020 at 15:09
  • but is there any trick to use big numbers with calculator package ? the same error with \SQUARE function, The good thing with calculator package is, it contains many other functions which i need too
    – AAA
    Nov 12, 2020 at 15:12
  • @AAA which functions do you need? xfp supports quite a few as well.
    – Skillmon
    Nov 12, 2020 at 15:13
  • @AAA in xfp's documentation there is a very brief list of functions supported inside of \fpeval. The syntax is mostly like what you'd use in other programming languages, so e.g. \fpeval{sin(2*pi/3)^4-ln(2)+sqrt(6)} should work.
    – Skillmon
    Nov 12, 2020 at 15:24
  • mod, exp,matix and vectors operations beside calculus functions
    – AAA
    Nov 12, 2020 at 15:25
-1

The calculator package can calculate up to 16,383.99998 (aka 214 − 2 × 10−5). So 263 > 16,383.99998, It can't calculate. Here's The cube table.

x x3
1 13 = 1
2 23 = 8
3 33 = 27
24 243 = 13,824
25 253 = 15,625
26 263 = 17,576
1
  • 1
    Welcome to the TeX Stack Exchange! While you do point out the problem, you don't seem to propose a solution at the moment. Could you provide an alternative to \CUBE for higher numbers?
    – Someone
    Aug 18 at 15:43

You must log in to answer this question.

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