Questions tagged [arithmetic]

60 questions
11
votes
2 answers

known benchmarks for floating point calculations?

I frequently have the problem that I have to perform some simplistic calculations, mostly products and sums of two or three quantities. I used to use the fp package for it, but it does look somewhat unmaintained. Now I've tried pgfmath, and like…
4
votes
3 answers

\numexpr with parentheses / order of operations

I feel very silly. Basically I want to divide the result of an addition with \numexpr, such as: (10 + 5) / 3 The problem is that if I put parentheses there, like \numexpr (10+5)/3 \relax my online editor gives me back a syntax error. The only way I…
Gaspa79
  • 143
4
votes
2 answers

More on formatting of long division

Among the several proposals for formatting long division in LaTeX, the one that has worked best for my purposes is the one for which the code appears below. It is necessary for me: to stop the process before it's over in order to comment on…
4
votes
3 answers

Arithmetic temporaries in tex

Can i call macros something like this \StrMid{\mystring}{\X}{\X+2}\par So, i would like to have running window of length 3. And for this end i would like to be able to use temporary unnamed local variable \X+2 as i can in C++.
Yola
  • 481
3
votes
2 answers

Modulo 2 binary long division in European notation

I need to represent binary modulo 2 long division in my tex document. Notation needed is same as https://en.wikipedia.org/wiki/Long_division#Eurasia under Austria, Germany, etc. I know about longdiv package, but it doesn't seem to support this. Is…
TexUser
  • 31
  • 2
3
votes
2 answers

How to do arithmetic without assignment?

I have known that I can use "advance...by..." to do arithmetic on number in TeX, but is there any way to do arithmetic without changing the value of number? For example, if I want to determine whether a number called X whose value is x satisfies…
Evian
  • 211
  • 1
  • 2
2
votes
1 answer

Increment/display the content of a (variable)/(section number) under latex?

To have something equivalent to echo of the shell. For instance in .tex file we have: \def \var{2} The content of var is $var How to edit the tex file in such a way we have as output: The content of var is 2? Especially, can we perform…
Courier
  • 133
1
vote
1 answer

Adding a number to command parameter and outputting it

I have a command that takes a single parameter. I want to add a constant number to that parameter and include it in the output. Something like (pseudo-code): \newcommand*{\label}[1]{% Here is the sum: {#1 + 20} } % elsewhere... \label{22) %…
me--
  • 377
  • 2
  • 8
1
vote
1 answer

Why is 'pt' printed when multiplying two point-based dimensions?

In this MWE: \documentclass{article} \begin{document} \dimen1=10pt \multiply\dimen1 by 20pt \rule{\dimen1}{10pt} \end{document} I multiply 10pt with 20pt, expecting a value of 200pt (which is also the case as shown by the resulting…
gablin
  • 17,006