How to use floor function in gnuplot

Here, the OP defines functions roundusing function floorc gnuplot. Help for floorsays:

gnuplot> help floor
 The `floor(x)` function returns the largest integer not greater than its
 argument.  For complex numbers, `floor` returns the largest integer not
 greater than the real part of its argument.

How can I use floor, I did:

gnuplot> floor(7.3)
         ^
         invalid command

Can I somehow change the number of decimal places, the number of which will be rounded to?

+4
source share
1 answer

To check or print the result of a function call, you must explicitly printit

gnuplot> print floor(7.3)
7

To change a related function roundto a round only in a decimal place, use the following

round(x) = x - floor(x) < 0.5 ? floor(x) : ceil(x)
round2(x, n) = round(x*10**n)*10.0**(-n)

and name it like

gnuplot> print round2(7.3456, 1)
7.3
gnuplot> print round2(7.3456, 2)
7.35
+5
source

All Articles