To some, Software Engineering doesn’t seem like an exact science and after all that might be correct because it is a lot about how people get their things done and not so much about numbers. Nevertheless, there are a couple of simple truths, which aren’t always surprizing, but often times capture well what practitioners experience all day.
I wanted to see how simple I can put them. How many of these simple facts I could find. How the image of Software Engineering looks after that. And how that list grows with my knowledge over time.
In my article about Kahan floating-point summation I showed how high precision summing can be realized with high speed. There is another efficient way to do high precision floating-point arithmetic but it isn’t supported by the common SIMD (Single Instruction Multiple Data) instruction sets. Nevertheless, it’s accuracy is significantly higher!
This posting is structured as follows: First I talk about “extended precision” in general, giving some historical information. In the second part I show how and when extended precision can be used in VC++ without assembler. In the third part I show some assembler code and do the accuracy and speed evaluation.
When I searched the web it wasn’t easy to find a simple function to calculate Butterworth lowpass filter coefficients, so I looked up the theory and did things on my own.
If you just want coefficients for a single filter specification, you can use the code generated by this nice online code generator. It will produce C-code that you can use for a specified samplerate and cutoff-frequency. It will also do Chebyshev and Bessel filters as well as lowpass, highpass, bandpass and bandstop filters for you.
However, if your program needs adjustable cutoff or samplerate, you can not use this script.
Summing floating-point numbers is trickier than most people think. For example ((x+y)+z) does not necessarily equal (x+(y+z)) with FP numbers. Also, it is easy to loose precision if two numbers of different magnitude are summed.
If you want to add several floating-point numbers, these rounding errors may sum up and make the result unusable.
Luckily, there is help on the way and it is called “Kahan Summation”.