Python论坛  - 讨论区

标题:Re: Re: [python-chinese] 一个数字显示问题,只是好奇

2004年04月14日 星期三 15:46

刘鑫 liux at gdcn.com
Wed Apr 14 15:46:40 HKT 2004

jackphil,您好! 

  问题就在于,这是浮点数,10.1-10和2.1-2实际上可能不同……

======== 2004-04-14 15:20:09 您在来信中写道: ========

应该不会,不然10.1中的0.1能精确表达,为什么2.1中的0.1不能表达呢
-----
刘鑫 写道: 
jackphil,您好! 

   应该是10.1可以精确表达为二进制浮点数的原因吧。
        个人猜想,大学时的基础课已经都还给老师了……脸红……

======== 2004-04-14 15:04:16 您在来信中写道: ========

2.00... 1我知是误差,10.1为什么好象没误差
----------
Qiangning Hong 写道: 
浮点数的二进制到十进制转换时会有误差

-----Original Message-----
From: python-chinese-bounces at lists.python.cn
[mailto:python-chinese-bounces at lists.python.cn] On Behalf Of jackphil
Sent: Wednesday, April 14, 2004 2:11 PM
To: python-chinese at lists.python.cn
Subject: [python-chinese] 一个数字显示问题,只是好奇


大家好!以下是我刚学Python时,拿Python当桌面计算器使用:)时碰到的现象,一
直也没能理解:
在交互环境直接输入数字2.1回车(没有print),回显是2.1000000000000001,OK,
我大概知道是怎么回事,2.5就显示2.5, 这都OK,但10.1为什么显示10.1?一直到
15.1,都精确回显,接下去又有尾巴了...001,我试到30.1...

Just for Fun!



_______________________________________________
python-chinese list
python-chinese at lists.python.cn
http://python.cn/mailman/listinfo/python-chinese
  

_______________________________________________
python-chinese list
python-chinese at lists.python.cn
http://python.cn/mailman/listinfo/python-chinese
  



= = = = = = = = = = = = = = = = = = = = = = 
        致
礼!

              刘鑫
              liux at gdcn.com
                 2004-04-14


_______________________________________________
python-chinese list
python-chinese at lists.python.cn
http://python.cn/mailman/listinfo/python-chinese
  



= = = = = = = = = = = = = = = = = = = = = = 
        致
礼!

              刘鑫
              liux at gdcn.com
                 2004-04-14
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20040414/c6f587a0/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号