2007年12月26日 星期三 13:34
是不是得要设个非常小的数,比方说e=0.00001 然后A-Bhttp://python.cn/pipermail/python-chinese/attachments/20071226/53ab5922/attachment.html
2007年12月26日 星期三 13:40
那不就是 A<chosen在126.com> wrote: > > 是不是得要设个非常小的数,比方说e=0.00001 > 然后A-B> 那么如果我要判断两个浮点数中的哪个小呢? > 诸位有什么建议?
2007年12月26日 星期三 13:49
既然已经认为|A-B|<cafeeee在gmail.com> 写道: > 那不就是 A> > On Dec 26, 2007 1:34 PM, chosen <chosen在126.com> wrote: > > > > 是不是得要设个非常小的数,比方说e=0.00001 > > 然后A-B > > 那么如果我要判断两个浮点数中的哪个小呢? > > 诸位有什么建议? > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese
2007年12月26日 星期三 14:28
那么可以这样:
if abs(A-B) < e:
# A等于B
elif A < B:
# A小于B
else:
# A大于B
或者:
if A-B <= -e:
# A小于B
if A-B >= e:
# A大于B
On Dec 26, 2007 1:49 PM, yuting cui <yutingcui在gmail.com> wrote:
> 既然已经认为|A-B|Zeuux © 2025
京ICP备05028076号