Questions tagged [floating-point]
The floating-point tag has no usage guidance.
31
questions
0
votes
0
answers
25
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
3
answers
543
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
65
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
59
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
42
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 ...
2
votes
1
answer
120
views
Rounding up to decimal pgfmath
I need to define a Roundup function that is "defined as the smallest number, specified to one decimal place, that is equal to or higher than its input." For example, Round up (4.02) is 4.1; ...
1
vote
1
answer
127
views
A four quadrant floating point inverse tangent function
After a chat discussion yesterday, I decided to write an inverse tangent function that normalizes the angle in the range [0,2\pi] (or [0,360] in degrees of course). Doing so was easy. My question is, ...
4
votes
1
answer
72
views
Getting rid of a floating point with Tikz and evaluate
Salutations wonderful people,
I think you will understand my tragic problem with a MWE:
\documentclass{article}
\input{tikz}
\begin{document}
\begin{tikzpicture}
\draw [->,>=latex] (-.5,0) --...
7
votes
2
answers
990
views
How to divide in LaTeX without it rounding or truncating?
I'm working on a diagram and I'm pretty new to LaTeX, so I've decided to try to do it using math instead of statically assigned values. I have come up with the following:
\newcommand\qoffset{14}
\...
1
vote
1
answer
81
views
Clash somewhere among \fpeval, \or, and \CountToken
(This is my first question here, sorry for any "side effects" of it...)
I'd like to implement that, depending on the value of \MyR (a number between 0 and 1, 1 excluded), the first/second/......
2
votes
2
answers
47
views
Scaling Times Table Exercises
I would like to create exercise worksheets based on random numbers that scale multiplication and division facts up and down.
For example, once a student learns that: 5*3=15, it is time to scale that ...
1
vote
1
answer
132
views
Why does pgf calculate arc sine incorrectly (by a lot)?
Reasonable imprecision is OK, but diverging from a calculator by entire 10 degrees is unacceptable.
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{math}
\tikzmath
{ \angle=...
1
vote
1
answer
63
views
How to get mantissa and exponent of a number from within pgf/fpu?
I need to get mantissa and exponent of a number from within pgf/fpu.
I found @egreg's solution from here, but this solution does not work inside fpu.
\documentclass[]{article}
\usepackage{pgf, tikz}
\...
3
votes
1
answer
124
views
pict2e: Cannot use decimal line slope argument inserted from macro
I am implementing nonstandard operators by drawing them as pictures using the pict2e package and then scaling them to fit in the various math modes. I store the picture's parameters in external macros ...
1
vote
3
answers
225
views
How to limit amount of numbers after comma in metapost?
I would like to limit floating point numbers inside a label:
beginfig(1)
for i=1 upto 5:
label.bot(textext("$" & (decimal (-0.8*i)) & "$"), (-0.8*i, -0.2));
endfig;
end;
Currently ...
7
votes
2
answers
417
views
ylim with negative floating point number
Could someone explain me why the following code compile perfectly :
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\pgfplotsset{/pgf/number format/.cd, 1000 sep={}, assume ...
0
votes
1
answer
85
views
How do I make a command to add fraction of \textheight space?
I would like to have a command that inserts a vertical space via
\myskip{.5}
which would be equivalent to skipping half the page.
I tried
\newcommand\myskip[1]{\vspace*{{#1}\textheight}}
But ...
2
votes
3
answers
688
views
How to convert datatypes?
I am trying to use datatools \DTLfetch to grab a real number from a database loaded from a .csv file, and then pass this numeric argument to \FPeval.
Problem is that \DTLfetch always seems to return ...
7
votes
1
answer
201
views
Input sanitization for \fp_eval
Is there a command that asks whether an argument to \fp_eval is a parse error or not? E.g.:
\fp_if_valid:nTF { 1+2.3*2 } { yes } { no } % yes
\fp_if_valid:nTF { 1+2.3* } { yes } { no } % no
I would ...
0
votes
2
answers
280
views
passing the product of two floating point numbers to a macro [duplicate]
I have a macro
\mywonderfulmacro{...}
that expects an ordinary floating point number in lieu of .... (For example,
\mywonderfulmacro{4.51}
is valid.) Now I would like to do something like this:
\...
1
vote
1
answer
302
views
Can FP read scientific notation?
I'm reading numbers from a file that are in scientific notation, and I'd like to do a simple calculation with them using FP. However, it's giving me the error FP error: Illegal character e found in ...
10
votes
1
answer
1k
views
How is floating-point arithmetic implemented in TeX
The TeXbook says that TeX only uses fixed-point arithmetic/integer arithmetic with very small units (essentially the same thing for our purposes). Why do modern TeX variants not support floating point ...
3
votes
1
answer
299
views
Convert Random \frac{a}{b} to Float? Is the question phrased properly?
How do I convert a randomly selected fraction in the [string?] form \frac{a}{b} to a [float?] form so that pgf can do calculations with it?
I am creating an exercise in which students practice ...
10
votes
2
answers
3k
views
Divide two lengths
How do I divide two lengths and get a length out?
\documentclass{article}
\newlength\A
\newlength\B
\newlength\C
\setlength\A{10pt}
\setlength\B{5pt}
\setlength\C{\dimexpr\A/\B\relax}
\begin{document}...
8
votes
1
answer
1k
views
Use floating point with calc
I wanted to use a pie chart in my document and tried this code example: http://www.texample.net/tikz/examples/pie-chart/
Now this seems to work perfectly with integer values but as for floating point ...
14
votes
5
answers
1k
views
Ratio arithmetic in plain TeX
I would like to calculate the ratio between two dimensions and produce a dimensionless quantity for use in further calculation in the process. I seem to be unable to do so. Specifically, I run into ...
8
votes
4
answers
576
views
Use the result of FPeval to color a table cell
I am trying to give a table cell a grayscale color value based on it's numeric value. So far I have the following code
\documentclass{article}
\usepackage{fp,xcolor,colortbl}
\FPeval{\resb}{0.5}
\...
1
vote
3
answers
3k
views
Plotting Floating point number when changes are very small in data
I want to plot the following data, i am using the CSV file, and pgfplotstable package.
(0,2.42130785530195E-02),
(113.8,2.42130785530195E-02),
(227.6,2.42130781357695E-02),
(341.3,2.42130779271445E-...
2
votes
1
answer
1k
views
How to get float numbers as parameter of \newcommand
I have defined a \newcommand function like into this code:
\documentclass{scrartcl}
\usepackage{pbox,calc}
\newcounter{pointsExo}
\setcounter{pointsExo}{4}
\newcounter{pointsSousTotal}
\setcounter{...
13
votes
4
answers
2k
views
Checking for valid floating point number
I want to do the following: I am generating a report which can be set to be in imperial or metric units. All values are originally in metric units, so in the case of imperial units all values should ...
7
votes
1
answer
934
views
Avoiding `Dimension too large' and `ill-formatted floating point' errors in tikz
I am attempting to draw some pictures using tikz, with the decorations library, and am encountering a `Dimension too large' error. I have read the 20+ other questions/answers about this error, and ...