Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
It can be as simple as declaring all your variables as int instead of float but many other things need to be taken into account before you proceed doing this.
Like If your program contains multiplications involving decimals less than one then you need to scale them up by some constant factor do your manipulations then scale down the result.
This is possible only if your input is integer and intermediate manipulations involve decimal constants.
This scaling would obviously introduce errors in the form of rounding off to the nearest integer. This error can be minimised by scaling your decimals appropriately. But too much scaling would also cause problems like overflow and saturation so you need to decide what your fixed point precision needs to be based on your scaling factor.
So all you have is error due to rounding off (when you have a low scaling value) and saturation and overflow errors due to Fixed point precision (due to high scaling) and a balance needs to be striked in choosing the scale factor based on your application.
Further high scaling value may also force you to use higher precision like long etc. but this may involve more computation.
Hope an example would clarify it more,
Assume a module which calculates the 'y' in y = mx+c given x where m and c are decimal constants , m = .15, c = 30.5.
Let input x always be an integer say = 250,
Then y if using the floating point would be = 250*.15+30.5 = 68
NOw converting constants to integers by scaling factor(sf) = 100,so c = 3050 and m = 15 (thus m and c are in integers).
Calculate y1 = (15*250+3050) = 6800.
Since the constants are scaled the out put needs to be scaled down = 6800/100 (this too is done as integer) = 68.
Luckily in this case there was no rounding off errors. But in most cases it would accur.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.