加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 乘法结果为负零

发布时间:2020-12-20 11:17:25 所属栏目: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 si
谁能告诉我为什么下面提到的代码的输出是负零?

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读