Questions tagged [floating-point]
The floating-point tag has no summary.
41 questions
6
votes
1
answer
114
views
How can I mainpulate the arguments in a function defined with \fp_new_function:n?
I just discovered that we can now create new functions (fp words) that can be evaluated inside \fp_eval:n per page 273 of interface3.pdf (it also seems to work with \fpeval). This is straightforward ...
3
votes
1
answer
129
views
Testing for floating point and int in expl3
I cannot figure out how to test if an argument is a floating point or integer using expl3.
Take this simple example where I convert \milk{number} into \dotfill, the number, and gallon or gallons with ...
7
votes
2
answers
269
views
Precision problem of pgfmath and xfp
The MWE is quite self-explaining:
\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfmath-xfp}
\usetikzlibrary{math}
\pgfmxfpdeclarefunction{test}{4}{
#1 * #3 - #2 * #4
}
\begin{...
3
votes
1
answer
202
views
Expandably getting the internal value of a floating point expression
In l3fp, there are many expandable functions that expand to different representations of the result of computing an fp expression: \fp_eval:n, \fp_to_decimal:n, \fp_to_dim:n, \fp_to_int:n, \...
3
votes
1
answer
103
views
Using dimens in floating point expressions
In my testing with l3benchmark, wrapping dimens and dimen expressions within a floating point expression is always faster with \dim_to_decimal:n than with \dim_to_fp:n. Yet, in kernel code, ...
2
votes
1
answer
154
views
Efficiently checking if an input can be parsed as a floating-point number in an expandable way in LaTex3?
I am trying to implement a function in LaTeX3 \check_if_fp:n that checks if an input can be parsed as a floating-point number (in an expandable way, so not using regexes). After a lot of thinking I ...
0
votes
1
answer
103
views
Branch to something when an expression cannot be evaluated by fpeval
I would like to design a \comparator expandable command that relies on fpeval that has 3 branches:
true branch when the comparison is equal to 1
false branch when the comparison is equal to zero
...
1
vote
2
answers
156
views
How to get rid of floating points while using \foreach
my question is quite simple, i want to construct a nuumberline for a homework and came up with the following code:
\begin{tikzpicture}
\draw(0,0)--(16,0);
\foreach \x/\y in {0/0,1.6/0.2,...,16.2/2.1}
\...
9
votes
1
answer
258
views
Calculating things with TikZ/pgf versus calculating things with l3fp
pgfmanual.pdf, VII Utilities, Repeating Things: The Foreach Statement, says:
\foreach \x in {0,0.1,...,0.5} {\x, } yields 0, 0.1, 0.20001, 0.30002, 0.40002,
and warns about rounding-errors causing ...
0
votes
0
answers
37
views
Floating point additions vs products
I'm writing a small macro to draw a curve given some parameters in Tikz:
\newcommand{\beznorm}[4]{%x, y, width, height
\def\x{#1}%
\def\y{#2}%
\def\w{#3}%
\def\h{#4}%
\def\sw{1/8 * ...
4
votes
2
answers
675
views
LaTeX(3) - Floating point number - Unit tests?
How are floating point macros tested?
Are comparisons made with other libraries not implemented in `LaTeX(3)'?
Is the IEEE standard for floating point arithmetic respected?
4
votes
3
answers
901
views
How to truncate a floating point number to an arbitrary decimal place?
Are there packages that provide a command that can truncate a floating point number not to the nearest integer, but to an arbitrary decimal place? For instance, 2.59 truncated to the first decimal ...
2
votes
2
answers
150
views
Floating points calculation problem (with pgfmathparse via length)
The subtraction of the calculated height of an input via sbox (in this case = 116.43562 pt) and 17.68 pt gives an incorrect result at the 5th floating point.
Here is the full tex file
\usepackage[T1]{...
0
votes
2
answers
105
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 ...
0
votes
1
answer
159
views
tikzpicture without float numbers
I wanted to make a tikzpicture, that includes numbers. It looks like this:
My problem is, that I have no idea how to get rid of the .0 after every number. Can someone help me to get integers instead ...