gnuplot对浮点数的内部表示是什么? [英] What is gnuplot's internal representation of floating point numbers?
问题描述
我确定答案是显而易见的,但是如果不查看源代码,我将找不到答案.
I'm sure the answer is obvious but I can't find it without looking at the source.
gnuplot对浮点数的内部表示是什么?是平台的double
吗?它是否使用自己的内部表示形式?可以做到任意精度吗?
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?
推荐答案
通过Google进行快速搜索,发现只要有可能,计算就会以双精度进行,但是,这里有一些小功能. IEEE双精度数字的范围应该大于1.797e308
,但是,如果您尝试给gnuplot一个如此大的数字,则会令人窒息:
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]
现在,如果您显示gnuplot的范围变量:
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的float是系统的双精度).
**(python's float is the system's double precision).
现在玩一点:
gnuplot> a = 8.98846567431e+307
gnuplot> a = 8.98846567432e+307
^
undefined value
因此gnuplot的浮点数可能会达到系统的最大值,以双精度(在可能的情况下)除以2.
So presumably gnuplot's floating point numbers go up to the system's maximum for double precision (where possible) divided by 2.
这篇关于gnuplot对浮点数的内部表示是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!