What is gnuplot's internal representation of floating point numbers?

本小妞迷上赌 提交于 2020-01-13 15:00:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!