Questions tagged [floating-point]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
62 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 ...
Vincent's user avatar
  • 5,257
1 vote
2 answers
78 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} \...
Daerker's user avatar
  • 13
9 votes
1 answer
190 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 ...
user avatar
0 votes
0 answers
31 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 * ...
Svalorzen's user avatar
  • 296
4 votes
2 answers
607 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?
projetmbc's user avatar
  • 13.3k
4 votes
3 answers
666 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 ...
Evan Aad's user avatar
  • 11.1k
2 votes
2 answers
85 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]{...
Bilal Yilmaz's user avatar
0 votes
2 answers
72 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 ...
sherlock's user avatar
  • 1,483
0 votes
1 answer
88 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 ...
Titanlord's user avatar
  • 541
2 votes
1 answer
180 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; ...
3isenHeim's user avatar
  • 2,107
2 votes
1 answer
184 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, ...
LaTeXereXeTaL's user avatar
4 votes
1 answer
90 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) --...
fbatch's user avatar
  • 147
7 votes
2 answers
1k 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} \...
Taggagii's user avatar
1 vote
1 answer
88 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/......
TFulop's user avatar
  • 75
2 votes
2 answers
51 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 ...
WeCanLearnAnything's user avatar
1 vote
1 answer
140 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=...
bp2017's user avatar
  • 3,776
1 vote
1 answer
67 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} \...
sergiokapone's user avatar
  • 5,578
3 votes
1 answer
134 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 ...
npjg's user avatar
  • 108
1 vote
3 answers
242 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 ...
flowian's user avatar
  • 163
7 votes
2 answers
447 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 ...
Viv's user avatar
  • 135
0 votes
1 answer
88 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 ...
JF Williams's user avatar
2 votes
3 answers
846 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 ...
alex dinovitser's user avatar
7 votes
1 answer
227 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 ...
Hood Chatham's user avatar
  • 5,467
0 votes
2 answers
304 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: \...
Labrador's user avatar
  • 245
1 vote
1 answer
335 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 ...
john_stech's user avatar
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 ...
Blaisorblade's user avatar
3 votes
1 answer
316 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 ...
WeCanLearnAnything's user avatar
11 votes
2 answers
4k 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}...
Carucel's user avatar
  • 1,035
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 ...
Someguy's user avatar
  • 345
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 ...
1010011010's user avatar
  • 6,357
8 votes
4 answers
597 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} \...
Brian Ecker's user avatar
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-...
Moody's user avatar
  • 332
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{...
lauhub's user avatar
  • 766
14 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 ...
thorsan's user avatar
  • 243
7 votes
1 answer
946 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 ...
Chris's user avatar
  • 1,183