Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Linux BC:十进制/浮点计算不准确_Python_Linux_Ubuntu_Command Line_32 Bit - Fatal编程技术网

Python Linux BC:十进制/浮点计算不准确

Python Linux BC:十进制/浮点计算不准确,python,linux,ubuntu,command-line,32-bit,Python,Linux,Ubuntu,Command Line,32 Bit,我正在Ubuntu 10.08上用BASH编写一个命令行程序 然而,我发现了一个问题: VSize=`echo 370.02 \* 1024 \* 1024 |bc` echo ${VSize} 387994091.52 然而,370.02*1024*1024=387994092 我已经安装了Python 2.6,甚至Python说: print 370.02*1024*1024 387994091.52 如何在Linux命令行中获得准确答案 可能吗 非常感谢 然而,370.02*1024*

我正在Ubuntu 10.08上用BASH编写一个命令行程序

然而,我发现了一个问题:

VSize=`echo 370.02 \* 1024 \* 1024 |bc`
echo ${VSize}
387994091.52
然而,370.02*1024*1024=387994092

我已经安装了Python 2.6,甚至Python说:

print 370.02*1024*1024
387994091.52
如何在Linux命令行中获得准确答案

可能吗

非常感谢

然而,370.02*1024*1024=387994092

不完全是

>>> 387994092. / 1024 / 1024
370.02000045776367
>>> 0.00000045776367 * 1024 * 1024
0.47999999803392002
不准确的是你

然而,370.02*1024*1024=387994092

不完全是

>>> 387994092. / 1024 / 1024
370.02000045776367
>>> 0.00000045776367 * 1024 * 1024
0.47999999803392002

不准确的是你。

啊……不准确的是谷歌。在谷歌中输入
370.02*1024*1024
,你会得到:
370.02*1024*1024=387994092
。我太信任谷歌了。啊……不准确的是谷歌。在谷歌中输入
370.02*1024*1024
,你会得到:
370.02*1024*1024=387994092
。我太信任谷歌了。