% This file is embedded in datatool-user.pdf version 3.4.5 2026-08-23
% Example 37 Decimal Functions (l3fp)
% Label: "ex:l3fpcalc"
% arara: pdflatex
% arara: pdfcrop
\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage[math=l3fp]{datatool-base}
\newcommand{\numA}{1023.5}
\newcommand{\numB}{54.75000}
\newcommand{\numC}{-20648.68}
\newcommand{\numlist}{32.456,0.15,-25,48.7,92} 
\begin{document}
\dtladd{\result}{\numA}{\numB}
$\numA + \numB = \result$. 

\dtladd{\result}{\result}{\numC}
Add $\numC$ to previous result. Updated result: \result. 

\dtladdall{\result}{\numlist}
Sum of all numbers in the set $\{\numlist\}$: \result. 

\dtlsub{\result}{\numA}{\numB}
$\numA - \numB = \result$. 

\dtlsub{\result}{\result}{\numC}
Subtract $\numC$ from previous result. Updated result: \result. 

\dtlmul{\result}{\numA}{\numB}
$\numA \times \numB = \result$. 

\dtlmul{\result}{\result}{\numC}
Multiply previous result by $\numC$. Updated result: \result. 

\dtldiv{\result}{\numA}{\numB}
$\numA \div \numB = \result$. 

\dtldiv{\result}{\result}{\numC}
Divide previous result by $\numC$. Updated result: \result. 

\dtlsqrt{\result}{\numA}
$\sqrt{\numA} = \result$. 

\dtlsqrt{\result}{9}
$\sqrt{9} = \result$. 

\dtlroot{\result}{\numA}{3}
$\sqrt[3]{\numA} = \result$. 

\dtlroot{\result}{8}{3}
$\sqrt[3]{8} = \result$. 

\dtlround{\result}{\numB}{1}
Round $\numB$ to 1dp: \result. 

\dtltrunc{\result}{\numB}{1}
Truncate $\numB$ to 1dp: \result. 

\dtlclip{\result}{\numB}
Clip $\numB$: \result. 

\dtlmin{\result}{\numA}{\numB}
Minimum of $\numA$ and $\numB$: \result. 

\dtlminall{\result}{\numlist}
Minimum value in the set $\{\numlist\}$: \result. 

\dtlmax{\result}{\numA}{\numB}
Maximum of $\numA$ and $\numB$: \result. 

\dtlmaxall{\result}{\numlist}
Maximum value in the set $\{\numlist\}$: \result. 

\dtlabs{\result}{\numC}
Absolute value of $\numC$: \result. 

\dtlneg{\result}{\numC}
Negate value of $\numC$: \result. 

\dtlmeanforall{\meanvalue}{\numlist}
Mean of all numbers in the set $\{\numlist\}$: \meanvalue. 

\dtlvarianceforall[\meanvalue]{\result}{\numlist}
Variance of all numbers in the set $\{\numlist\}$ (using previously calculated mean): \result. 

\dtlvarianceforall{\result}{\numlist}
Variance of all numbers in the set $\{\numlist\}$ (not using previously calculated mean): \result. 

\dtlsdforall[\meanvalue]{\result}{\numlist}
Standard deviation of all numbers in the set $\{\numlist\}$ (using previously calculated mean): \result. 

\dtlsdforall{\result}{\numlist}
Standard deviation of all numbers in the set $\{\numlist\}$ (not using previously calculated mean): \result. 
\end{document}
