Debian Codegraph @

texmf-dist/doc/latex/datatool/datatool-user-examples/datatool-user-example037.tex

raw
1 % This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04
2 % Example 37 Decimal Functions (l3fp)
3 % Label: "ex:l3fpcalc"
4 % arara: pdflatex
5 % arara: pdfcrop
6 \documentclass[12pt]{article}
7 \pagestyle{empty}
8 \usepackage[math=l3fp]{datatool-base}
9 \newcommand{\numA}{1023.5}
10 \newcommand{\numB}{54.75000}
11 \newcommand{\numC}{-20648.68}
12 \newcommand{\numlist}{32.456,0.15,-25,48.7,92}
13 \begin{document}
14 \dtladd{\result}{\numA}{\numB}
15 $\numA + \numB = \result$.
16
17 \dtladd{\result}{\result}{\numC}
18 Add $\numC$ to previous result. Updated result: \result.
19
20 \dtladdall{\result}{\numlist}
21 Sum of all numbers in the set $\{\numlist\}$: \result.
22
23 \dtlsub{\result}{\numA}{\numB}
24 $\numA - \numB = \result$.
25
26 \dtlsub{\result}{\result}{\numC}
27 Subtract $\numC$ from previous result. Updated result: \result.
28
29 \dtlmul{\result}{\numA}{\numB}
30 $\numA \times \numB = \result$.
31
32 \dtlmul{\result}{\result}{\numC}
33 Multiply previous result by $\numC$. Updated result: \result.
34
35 \dtldiv{\result}{\numA}{\numB}
36 $\numA \div \numB = \result$.
37
38 \dtldiv{\result}{\result}{\numC}
39 Divide previous result by $\numC$. Updated result: \result.
40
41 \dtlsqrt{\result}{\numA}
42 $\sqrt{\numA} = \result$.
43
44 \dtlsqrt{\result}{9}
45 $\sqrt{9} = \result$.
46
47 \dtlroot{\result}{\numA}{3}
48 $\sqrt[3]{\numA} = \result$.
49
50 \dtlroot{\result}{8}{3}
51 $\sqrt[3]{8} = \result$.
52
53 \dtlround{\result}{\numB}{1}
54 Round $\numB$ to 1dp: \result.
55
56 \dtltrunc{\result}{\numB}{1}
57 Truncate $\numB$ to 1dp: \result.
58
59 \dtlclip{\result}{\numB}
60 Clip $\numB$: \result.
61
62 \dtlmin{\result}{\numA}{\numB}
63 Minimum of $\numA$ and $\numB$: \result.
64
65 \dtlminall{\result}{\numlist}
66 Minimum value in the set $\{\numlist\}$: \result.
67
68 \dtlmax{\result}{\numA}{\numB}
69 Maximum of $\numA$ and $\numB$: \result.
70
71 \dtlmaxall{\result}{\numlist}
72 Maximum value in the set $\{\numlist\}$: \result.
73
74 \dtlabs{\result}{\numC}
75 Absolute value of $\numC$: \result.
76
77 \dtlneg{\result}{\numC}
78 Negate value of $\numC$: \result.
79
80 \dtlmeanforall{\meanvalue}{\numlist}
81 Mean of all numbers in the set $\{\numlist\}$: \meanvalue.
82
83 \dtlvarianceforall[\meanvalue]{\result}{\numlist}
84 Variance of all numbers in the set $\{\numlist\}$ (using previously calculated mean): \result.
85
86 \dtlvarianceforall{\result}{\numlist}
87 Variance of all numbers in the set $\{\numlist\}$ (not using previously calculated mean): \result.
88
89 \dtlsdforall[\meanvalue]{\result}{\numlist}
90 Standard deviation of all numbers in the set $\{\numlist\}$ (using previously calculated mean): \result.
91
92 \dtlsdforall{\result}{\numlist}
93 Standard deviation of all numbers in the set $\{\numlist\}$ (not using previously calculated mean): \result.
94 \end{document}