如何检测double的有效数字 [英] How to detect a double's significant digits

查看:176
本文介绍了如何检测double的有效数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好...我怎样才能找到有效数字的位数(到小数点右边的

),是双倍的?至少,我认为*

这就是我要求的。例如:


0.103 - > 3

0.0103 - > 4

0.00103 - > 5

0.000103 - > 6

0.0000103 - > 7

提前致谢!

- 史蒂夫(先生************ @ hotmail.com)

Hi all... How can I find out the number of significant digits (to the
right of the decimal place, that is) in a double? At least, I *think*
that''s what I''m asking for. For instance:

0.103 --> 3
0.0103 --> 4
0.00103 --> 5
0.000103 --> 6
0.0000103 --> 7

Thanks in advance!
--Steve (mr************@hotmail.com)

推荐答案

有效数字是会计概念。因此,只有她知道她的b / b
测量的精确度才能跟踪这些。


Koan当天:


0.1的有效数字是多少?


提示:
Significant digits are an accounting concept. As such, it is up to the
accountant to keep track of these as only she knows the precision of her
measurements.

Koan for the day:

What are the significant digits of 0.1?

Hint:
`0.1`



James

05年4月2005年5月10日上午37点,所以说mrstephengross:大家好...我怎样才能找到双倍的有效位数(小数点右边的那个)?至少,我*认为*
这就是我要求的。例如:

0.103 - > 3
0.0103 - > 4
0.00103 - > 5
0.000103 - > 6
0.0000103 - > 7

提前致谢!
- 史蒂夫(先生************ @ hotmail.com)


James
On Thursday 05 May 2005 10:37 am, so sayeth mrstephengross: Hi all... How can I find out the number of significant digits (to the
right of the decimal place, that is) in a double? At least, I *think*
that''s what I''m asking for. For instance:

0.103 --> 3
0.0103 --> 4
0.00103 --> 5
0.000103 --> 6
0.0000103 --> 7

Thanks in advance!
--Steve (mr************@hotmail.com)



-

James Stroud,博士

加州大学洛杉矶分校基因组学和蛋白质组学研究所

Box 951570

洛杉矶,CA 90095

http:// www.jamesstroud.com/


那么我怎样才能得到我想要的那种信息呢?


例如:


0.103 - > 3

0.0103 - > 4

0.00103 - > 5

0.000103 - > 6

0.0000103 - > 7

任何想法?

- 智慧

So how can I get the kind of information I want then?

For example:

0.103 --> 3
0.0103 --> 4
0.00103 --> 5
0.000103 --> 6
0.0000103 --> 7

Any ideas?
--Steve


fl = 1.0002

x = str(fl)

pos = x.find(''。'')

print len(x [pos + 1:] )
fl = 1.0002
x = str(fl)
pos = x.find(''.'')
print len( x[pos+1:] )
4



mrstephengross写道:

大家好......我怎样才能找到双倍的有效位数(小数点右边的那个)?至少,我*认为*
这就是我要求的。例如:

0.103 - > 3
0.0103 - > 4
0.00103 - > 5
0.000103 - > 6
0.0000103 - > 7

提前致谢!
- 史蒂夫(mr************@hotmail.com)


mrstephengross wrote:
Hi all... How can I find out the number of significant digits (to the
right of the decimal place, that is) in a double? At least, I *think*
that''s what I''m asking for. For instance:

0.103 --> 3
0.0103 --> 4
0.00103 --> 5
0.000103 --> 6
0.0000103 --> 7

Thanks in advance!
--Steve (mr************@hotmail.com)





这篇关于如何检测double的有效数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆