Questions tagged [floating-point]

The tag has no usage guidance.

28 questions
Filter by
Sorted by
Tagged with
44 views

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 ...
24 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 ...
30 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; ...
59 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, ...
63 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) --...
456 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} \...
61 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/......
36 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 ...
119 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=...
46 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} \...
99 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 ...
185 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 ...
318 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 ...
68 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{\vspace*{{#1}\textheight}} But ...
415 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 ...
165 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 ...
205 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: \...
248 views

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 ...
944 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 ...
277 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 ...
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}...
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 ...
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 ...
531 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} \...
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-...
928 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{...