Questions tagged [floating-point]

The tag has no usage guidance.

1
vote
2answers
69 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
2answers
172 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 ...
3
votes
1answer
84 views

Problem to plot data with dates using an external file

Using logs to make statistics, I have a large number of data which contains two columns, like this (dd-mm-aaaa hh-mm float) 27-04-2018 04:43 7.78269552 27-04-2018 04:44 7.901522832 27-04-2018 ...
0
votes
1answer
33 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 ...
0
votes
2answers
76 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 ...
5
votes
0answers
97 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
2answers
77 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
1answer
166 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
1answer
485 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
1answer
226 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 ...
6
votes
2answers
1k 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}...
7
votes
1answer
724 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
5answers
871 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
4answers
414 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
3answers
1k 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
1answer
588 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
4answers
957 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
1answer
808 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 ...