python – 乘法结果为负零

谁能告诉我为什么下面提到的代码的输出是负零?

a * b = -0

这里’a’是long类型,b是十进制类的对象…..如果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.

点赞