Groups
Groups
Sign in
Groups
Groups
Shanghai Linux User Group
Conversations
Labels
About
Send feedback
Help
mod in Python
6 views
Skip to first unread message
Zhao Quan
unread,
May 15, 2013, 5:22:32 AM
5/15/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sh...@googlegroups.com
今天在python中做%运算得到了很奇怪的结果
>>> 123.4 % 10
3.4000000000000057
>>> 1.2 % 10
1.2
>>> 100 %10
0
>>> 100.1 % 10
0.09999999999999432
大家看看何解?
Úcarenya
unread,
May 15, 2013, 5:30:30 AM
5/15/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sh...@googlegroups.com
没看出有什么不正常, Python默认提供定精度运算,和大部分POSIX工具一样。
如果要高精度计算,
dc <<< '100.1 10 %p'
需要别的模块
> --
> -- You received this message because you are subscribed to the Google Groups
> Shanghai Linux User Group group. To post to this group, send email to
>
sh...@googlegroups.com
. To unsubscribe from this group, send email to
>
shlug+un...@googlegroups.com
. For more options, visit this group at
>
https://groups.google.com/d/forum/shlug?hl=zh-CN
> ---
> 您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”论坛。
> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到
>
shlug+un...@googlegroups.com
。
> 要查看更多选项,请访问
https://groups.google.com/groups/opt_out
。
>
--
- Úcarenya - infernoxu at gmail dot com
-
http://ucarenya.com/
Reply all
Reply to author
Forward
0 new messages