python中的双值

2024-05-12 20:30:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我有656364.53这样的值,必须从文本文件中读取。从我的编程经验中,我了解到is value采用double数据类型,作为适当的值保留。

然而,在python中,似乎只有float或单精度值。因此根据我的经验,这些价值观在阅读时会发生变化。

如何在python中获得双精度值。


Tags: isvalue编程精度经验float数据类型double
2条回答

如果要对这些数据执行数学运算,精度是个问题,我建议您看看decimal data type我们遇到的浮点错误问题。

Decimal “is based on a floating-point model which was designed with people in mind, and necessarily has a paramount guiding principle – computers must provide an arithmetic that works in the same way as the arithmetic that people learn at school.”

根据documentation

Floating point numbers are usually implemented using double in C; information about the precision and internal representation of floating point numbers for the machine on which your program is running is available in sys.float_info.

相关问题 更多 >