One question that has been gnawing at me lately was the notion of significant figures, and how they relate to software. With regards to my limited academic experience on the subject, we're taught that an answer cannot be more precise than the measurement as that would be a dishonest answer.

Furthermore, the procedure for determining the number of significant digits to use depends on the operation used to arrive at that value. Not only that, there is a protocol for determining if a digit counts as significant at all. For example, the number 1200 only has 2 significant digits.

What I am trying to understand is how this cumbersome, and error-prone task is actually handled in industry. Will those of you who have professional experience in software which deals with measurements and calculations as it applies to uncertainty please shed some light on this question?

If you reply, please give a reason as to why you might be authoritative, such as prior held position and pertaining project (within bounds of your NDA), or anything you feel might lend credence to why anyone should take what you say seriously.

I appreciate all replies, and thank you for taking the time to read my request.

# Significant Figures in Scientific Software

Page 1 of 1## 3 Replies - 825 Views - Last Post: 04 April 2016 - 09:19 AM

##
**Replies To:** Significant Figures in Scientific Software

### #2

## Re: Significant Figures in Scientific Software

Posted 30 March 2016 - 02:36 PM

It's nonsense.

More precisely, the philosophy behind it is OK, and it's fine for manual calculations but the detail doesn't translate well to software.

The problem is that people think that the base 10 representation of a number is the same thing as the number. In my school physics class, the rule of thumb was three significant figures. The number 1234 would be 1230. However, if you write 1234 in hex, you get 4D2. 1230 is 4CE. The rounding had no advantage in simplifying things here. In binary, 1234 and 1230 are 10011010010 and 10011001110. Again, this rounding makes no sense since binary is difficult for humans to understand at a glance. If you are counting in pebbles it looks like this:

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

..................................

If you were really working with pebbles, the mathematical operations would look a lot different. Addition would be putting more pebbles into your bucket. Division would involve scales. Multiplication would be very difficult indeed (where would the extra pebbles come from?) but the idea of significant figures is right out the window!

Significant figures is a useful idea for manual calculations but for computer representation it's just silly. In fact, introducing it is likely to end up with rounding errors.

However, the idea that your answer is only as accurate as your measurements is valid so what can you do? If you have error bars on your measurements, you could do the calculations to work them through your calculation. It's quite a fun exercise to write a class to represent numbers with error bars and define the mathematical operations for working with them. A better option is available when you have repeated measurements because then you have a statistical distribution to work with.

Finally, when it comes to displaying the numbers people are fickle beings. People don't care how many digits before the decimal point you output but if you show more than two or three after the decimal point, they get all worked up about it. I tend to choose a formatting option that makes things look sensible, knowing well that the calculation under the hood or stored in the database has preserved as much information as possible.

More precisely, the philosophy behind it is OK, and it's fine for manual calculations but the detail doesn't translate well to software.

The problem is that people think that the base 10 representation of a number is the same thing as the number. In my school physics class, the rule of thumb was three significant figures. The number 1234 would be 1230. However, if you write 1234 in hex, you get 4D2. 1230 is 4CE. The rounding had no advantage in simplifying things here. In binary, 1234 and 1230 are 10011010010 and 10011001110. Again, this rounding makes no sense since binary is difficult for humans to understand at a glance. If you are counting in pebbles it looks like this:

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

....................................................................................................

..................................

If you were really working with pebbles, the mathematical operations would look a lot different. Addition would be putting more pebbles into your bucket. Division would involve scales. Multiplication would be very difficult indeed (where would the extra pebbles come from?) but the idea of significant figures is right out the window!

Significant figures is a useful idea for manual calculations but for computer representation it's just silly. In fact, introducing it is likely to end up with rounding errors.

However, the idea that your answer is only as accurate as your measurements is valid so what can you do? If you have error bars on your measurements, you could do the calculations to work them through your calculation. It's quite a fun exercise to write a class to represent numbers with error bars and define the mathematical operations for working with them. A better option is available when you have repeated measurements because then you have a statistical distribution to work with.

Finally, when it comes to displaying the numbers people are fickle beings. People don't care how many digits before the decimal point you output but if you show more than two or three after the decimal point, they get all worked up about it. I tend to choose a formatting option that makes things look sensible, knowing well that the calculation under the hood or stored in the database has preserved as much information as possible.

This post has been edited by **cfoley**: 30 March 2016 - 02:37 PM

### #3

## Re: Significant Figures in Scientific Software

Posted 04 April 2016 - 07:04 AM

cfoley, on 30 March 2016 - 05:36 PM, said:

However, the idea that your answer is only as accurate as your measurements is valid so what can you do? If you have error bars on your measurements, you could do the calculations to work them through your calculation. It's quite a fun exercise to write a class to represent numbers with error bars and define the mathematical operations for working with them.

Darn you cfoley!

I'm here at home sick and I was just casually reading through the forum and I ran across this thread. Now, I'm here trying to recall rules about significant figures, error propagation, and re-reading What Every Computer Scientist Should Know About Floating-Point Numbers when I really should be resting. />

I also learned something new: Kahan Summation.

So now if I just stay in bed watching Buffy the Vampire Slayer the rest of the day, I can say that the day was not a complete waste because I learned something new today.

### #4

## Re: Significant Figures in Scientific Software

Posted 04 April 2016 - 09:19 AM

Hope you feel better soon. I had not heard of kahan summation either so thanks for sharing.

Page 1 of 1