简体   繁体   English

Cython 精度和数据类型

[英]Cython precision and data types

I understand in cython some precision is lost, because a cython float is not the same as a python float.我知道在 cython 中会丢失一些精度,因为 cython 浮点数与 python 浮点数不同。 Consequently I redifined a variable as follows:因此,我重新定义了一个变量,如下所示:

cdef long double variable=1*10**-10
print variable
0.0

This failed however:然而,这失败了:

cdef long double variable=0.0000000001
print variable
1e-10

was successful.那是成功的。 I need to perform relatively precise calculations so I am keen to understand this behavior.我需要执行相对精确的计算,所以我很想了解这种行为。

See here, it seems this bug is fixed in Cython 3.0看到这里,这个bug似乎在Cython 3.0中修复了

https://github.com/cython/cython/issues/2133 https://github.com/cython/cython/issues/2133

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM