[sdiy] Accuracy with integer maths

rburnett at richieburnett.co.uk rburnett at richieburnett.co.uk
Tue Feb 4 16:09:38 CET 2014


> Everything I know I wrote down here:
> 
> http://blog.credland.net/2013/09/binary-fixed-point-explanation.

I'm getting a "Sorry, the page you were looking for in this blog does 
not exist" on that URL here.

Tom, if you are going to truncate a 16-bit result to 8-bits accuracy you 
really should preserve the 9th bit so that you can test it and decide 
whether to round the value up or down.  Think what you would do if you 
were going to round a decimal number like "317" to the nearest ten.  
Although you're only going to keep the top two digits (the '3' and the 
'1',) you need to test the units digit to see if the result should be 
rounded up to 320 or down to 310.  (I usually implement rounding by 
adding in a half to produce a carry if the fractional part that you are 
going to chop off was greater than 0.5, then do a plain truncate.  This 
eliminates any branching in the code so the execution time is always 
constant, and you don't incurr any pipeline stalls, etc.)

Most hardware multipliers will give you all of the bits of the result 
automatically, so unless you are hard-coding your own software-multiply 
routine I'm not sure where you would make optimisations if you don't 
need all the bits of the result.

What are you actually using this multiply for?!?!?  Are you trying to do 
some clever DSP stuff on a general purpose CPU?

-Richie,



More information about the Synth-diy mailing list