ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DeMattia/Python/sigRound.py
Revision: 1.1
Committed: Wed Feb 6 18:30:48 2008 UTC (17 years, 2 months ago) by demattia
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Error occurred while calculating annotation data.
Log Message:
*** empty log message ***

File Contents

# Content
1 # #!/usr/bin/python
2
3 # Evaluates the digits to be used with the round function in order to have
4 # the first two significant figures
5
6
7 def sigRound(error):
8 tempErr = error
9 digits = 0
10 if( int(tempErr) == 0 ):
11 while (int(tempErr) == 0):
12 tempErr = tempErr*10
13 digits += 1
14 else:
15 digits = 1
16 while (int(tempErr) != 0):
17 tempErr = tempErr/10
18 digits -= 1
19
20 # Check for rounding
21 if( int(round(error,digits)*10**(digits-1)) != 0 ):
22 return digits
23 return digits+1
24
25 # Round the number to the two significant figures of the error
26 ##a = 0.1235131223183
27 ##aErr = 0.0012392882843
28
29 ##digits = sigRound(aErr)
30 ##print "digits =", digits
31
32 ##a = round(a,digits)
33 ##aErr = round(aErr,digits)
34
35 ##print a, "+-", aErr