有人能告诉我为什么下面提到的代码的输出是负零吗??
a * b = -0
这里'a'是long类型,b是decimal类的对象.....如果a=-28和b=0,那么输出是-0
最佳答案
来自 Python decimal
文档:
The signed zeros can result from calculations that underflow. They keep the sign that would have resulted if the calculation had been carried out to greater precision. Since their magnitude is zero, both positive and negative zeros are treated as equal and their sign is informational.
关于python - 乘法结果为负零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5131428/