Questions tagged [floating-point]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
6
votes
2answers
314 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
1answer
47 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
2answers
31 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
1answer
112 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
1answer
35 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
1answer
61 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
3answers
142 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
254 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
1answer
49 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
3answers
195 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
1answer
142 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
138 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
221 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
732 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
267 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 ...
11
votes
2answers
2k 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
1answer
915 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
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
4answers
472 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
2k 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
772 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
1k 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
868 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 ...