Questions tagged [xfp]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
47 views

"FPeval" along with "clip" when multiplied with 10 gives wrong answer while it does not happen with other numbers

\newcounter{tenMarksQ} \setcounter{tenMarksQ}{0} \DTLforeach{Q}{\Marks=Marks} { \ifnum\Marks=10 \addtocounter{tenMarksQ}{1} \fi } \FPeval{\10}{clip(10*\thetenMarksQ)} \section{ELABORATE ON:...
Srini Vasan's user avatar
3 votes
2 answers
117 views

How to expand \fpeval{} results numerically?

I' m trying to use xfp to create some automated homework solutions. For short documents it works like a charm, but for longer one the compiling time grows exponentially. For example: \def\GDUbeta{30} %...
Guanyang Xue's user avatar
4 votes
3 answers
282 views

xfp - Huge integers - Why is \inteval less accurate then \fpeval?

I was trying to print the first few terms of hyperfactorials, which are defined by H(0)=1 and H(n)=H(n-1)*n^n. When fpeval is used for calculation and inteval is used for printing: \documentclass{...
inge3515's user avatar
2 votes
1 answer
109 views

\dimeval for pdflatex?

I'm using pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian). In a recent question, I have been provided with two excellent answers that unfortunately both make use of \dimeval. This command is ...
vwegert's user avatar
  • 2,855
3 votes
1 answer
574 views

How to calculate a mean in LaTeX?

I'd like to set up a LaTeX template for grading, which would contain several categories that are graded individually using A-F by the user of the template. Out of these, the final grade has to be ...
krab1k's user avatar
  • 105
4 votes
1 answer
198 views

problem when using radians with tikz

My initial problem occurred with this code: \def\a{pi/2} \pgfmathparse{\a r}\pgfmathresult output : 89.99937 When I modified the macro \a thus \def\a{pi} I get the error: Package PGF Math Error: ...
Alain Matthes's user avatar
0 votes
2 answers
63 views

Latex complaining about large numbers

To pretty print large numbers with numeric suffix, this solution works fine, except the last test case (the poster already indicated that, so it is not unexpected). Surprisingly, 6260563123 is ...
sherlock's user avatar
  • 1,423
4 votes
2 answers
156 views

Adding parameters, inside a newcommand for partial derivatives

Using \usepackage{xfp}, I have created the following command: \newcommand{\ppdv}[5]{\dfrac{\partial^{\fpeval{#3 + #5}} #1}{\partial {#2}^{#3} \partial {#4}^{#5}}} So that, for example, if I type: \...
FacuO.Z.'s user avatar
  • 161
3 votes
2 answers
101 views

expl3 empty variable when called by another macro

Here is the boiled-down extract of what I'm trying to do. Apologies beforehand if some of the computations do not make sense, I've modified them for the sake of simplicity. Basically, I've a function ...
3isenHeim's user avatar
  • 2,097
2 votes
1 answer
274 views

How to set specific seed for random number generator in expl3 for use with xfp

I am using the xfp package to generate some random numbers, and am trying to figure out how to specify a specific random seed for the pseudo random number generator (so it gives the same results ...
Bob's user avatar
  • 125
6 votes
2 answers
288 views

On the strange calculations calling xfp, Tikz, sqrt, and ^2

As we now the square root of (-3)^2+(-4)^2 is the square root of 25 equal to 5. However we got a strange error calling xfp package and Tikz saying: \LaTeX3 error: Invalid operation sqrt(-25) Below is ...
Aria's user avatar
  • 1,523
3 votes
2 answers
488 views

Classes/objects (OOP) in LaTeX

I want to create classes/objects using normal LaTeX commands to represent member variables and member functions. I came up with the following approach: \documentclass{article} \usepackage{expl3} \...
Michael's user avatar
  • 133
4 votes
1 answer
107 views

Expandable set of divisors with xfp?

I wrote some code to print the set of divisors but it is not expandable. \input expl3-generic.tex \def\divisors#1{% \def\L{1}% \def\M{#1}% \def\x{2}% \loop \ifnum \fpeval{floor(#1/...
Weißer Kater's user avatar
4 votes
1 answer
178 views

Is there an interface to define functions in xfp?

Some functions are defined in xfp. Example: You can write something like \fpeval{max(1, 2, 3, 4)} and get 4 as the result. I would like to define functions like crbt(x) = x^(1/3) or the greatest ...
Weißer Kater's user avatar
3 votes
1 answer
354 views

xfp: zerofill at fpeval

I need some calculations with fpeval, where I want numbers like '21' outwritten as '21.0' with one zero after the point. Is this possible at xfp.sty? \documentclass[margin=5pt, varwidth]{standalone} \...
cis's user avatar
  • 7,529
5 votes
2 answers
347 views

Evaluating expressions using xfp

I want to generate two integer random numbers for the radius (r) and heigth (h) of a cilinder, in a certain question of my exam. I am using the package xfp to generate the random numbers. However, I ...
Angelo Aliano Filho's user avatar
4 votes
3 answers
163 views

Removing cumulative sum + defining local variables + if

The below code is wrong but it illustrates what I am trying to achieve. How would you write the g command? \usepackage{xfp} \newcommand{\f}[1]{ \inteval{(#1 - \a) / (\b - \a)} } \newcommand{\g}[1]{...
Filippo Guenzi's user avatar
0 votes
2 answers
126 views

Is it possible to evaluate an integral using the xfp package?

I am curious if it is possible to evaluate an integral using the xfp package using tex language? \fpeval{\int_{-1}^{1}\frac{1}{\sqrt{1 - x^2}}dx}} Just throwing out the idea. I know I can easily do ...
Christopher Creveling's user avatar
0 votes
0 answers
77 views

How to create a line-spacing command like `\doublespacing` but for an arbitrary factor?

The setspace package provides a couple of multi-line spacing commands, like \doublespacing. But as far as I can see, it does not provide a simple spacing command by an arbitrary factor. It provides \...
Daniel's user avatar
  • 1,777
2 votes
1 answer
217 views

On the xfp package: ternary operator x ? y : z

On page 1/2 xfp package we see ternary operator x ? y : z as a valid boolean expression. it deserves the author puts at least the definition of this. In C I was told we have: variable = Expression1 ? ...
Aria's user avatar
  • 1,523
7 votes
1 answer
171 views

The difference between {\x >\y} and {\x >? \y} in xfp package?

On page 1/2 of xfp package we see x >? y as a valid comparison operator. Is it different from x>y? I think they are equivalent based on my following code, but not sure: \documentclass{article} ...
Aria's user avatar
  • 1,523
1 vote
1 answer
309 views

On the xfp package: Comparison

On page 1/2 of the xfp package we read: The floating point expressions may comprise:Comparison operators: x < y, x <= y, x >? y, x ! = y etc. However they did not show an example. Below I ...
Aria's user avatar
  • 1,523