Credits | Overview | Plotting Styles | Commands | Terminals |
---|
Gnuplot integer variables are stored with 64 bits of precision if that is supported by the platform.
Gnuplot complex and real variables are on most platforms stored in IEEE754 binary64 (double) floating point representation. Their precision is limited to 53 bits, corresponding to roughly 16 significant digits.
Therefore integers with absolute value larger than 2^53 cannot be uniquely represented in a floating point variable. I.e. for large N the operation int(real(N)) may return an integer near but not equal to N.
Furthermore, functions that convert from a floating point value to an integer by truncation may not yield the expected value if the operation depends on more than 15 significant digits of precision even if the magnitude is small. For example int(log10(0.1)) returns 0 rather than -1 because the floating point representation is equivalent to -0.999999999999999... See also overflow.
int(x) returns the integer part of its argument, truncated toward zero. If |x| > 2^63, i.e. too large to represent as an integer, NaN is returned. If |x| > 2^52 the return value will lie within a range of neighboring integers that cannot be distinguished due to limited floating point precision. See integer conversion.
floor(x) returns the largest integer not greater than the real part of x. If |x| > 2^52 the true value cannot be uniquely determined; in this case the return value is NaN. See integer conversion.
ceil(x) returns the smallest integer not less than the real part of x. If |x| > 2^52 the true value cannot be uniquely determined; in this case the return value is NaN. See integer conversion.
round(x) returns the integer nearest to the real part of x. If |x| > 2^52 the true value cannot be uniquely determined; in this case the return value is NaN. See integer conversion.