2004年04月14日 星期三 15:46
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
Zeuux © 2025
京ICP备05028076号