问题
I'm sure the answer is obvious but I can't find it without looking at the source.
What is gnuplot's internal representation of floating point numbers? Is it the platform's double? Does it use its own internal representation? Can it do arbitrary precision?
回答1:
A quick google search will turn up that calculations are done in double precision whenever possible, however, there's a little sublety going on here. The range of an IEEE double precision number should go up to more than 1.797e308, however, if you try to give gnuplot a number that big, it chokes:
gnuplot> plot '-' u 0:($1/2.)
input data ('e' ends) > 1.7976931348623157e+308
input data ('e' ends) > 30
input data ('e' ends) > e
Warning: empty x range [1:1], adjusting to [0.99:1.01]
Warning: empty y range [15:15], adjusting to [14.85:15.15]
Now if you show gnuplot's range variables:
gnuplot> show variables all
You'll see some things that are a little strange:
GPVAL_DATA_X2_MIN = 8.98846567431158e+307
GPVAL_DATA_X2_MAX = -8.98846567431158e+307
With this number repeated a few times. (Note that this number is roughly correct):
gnuplot> !python -c 'import sys; print sys.float_info.max/2.'
8.98846567431e+307
**(python's float is the system's double precision).
Now a little playing around:
gnuplot> a = 8.98846567431e+307
gnuplot> a = 8.98846567432e+307
^
undefined value
So presumably gnuplot's floating point numbers go up to the system's maximum for double precision (where possible) divided by 2.
来源:https://stackoverflow.com/questions/14052115/what-is-gnuplots-internal-representation-of-floating-point-numbers