| Author |
Message |
smartshashi
Joined: 11 Aug 2004 Posts: 63
|
10 Feb 2009 11:43 convert floating point to binary assembler |
|
|
|
|
| I am working on butterworth IIR filter & I have to implement it in ARM assembly. This filter have some fractional coefficients. Can anybody explain me how to convert this fractional coefficients in hex so that I can use it in assembly without changing the response of filter?
|
|
| Back to top |
|
 |
Kral
Joined: 28 Mar 2005 Posts: 1182 Helped: 187
|
10 Feb 2009 23:45 convert to negative floating number to hexa |
|
|
|
|
smartshashi,
You can easily convert decimal fractions to hex using a calculator. Supporse you're working with 16 bit numbers.
Step 1: multiply the fraction by 65536 (2^16)
Step 2: Convert to hex. This is easy on a scientific calculator.
The result is a binary fraction with the MSB having a weight of .5, the 2nd MSB having a weight of .25, etc.
.
Example, convert 0.75 to hex
Step 1: 0.75 X 65536 = 49152
Step 2 convert to hex = C000 (.5 + .25)
.
For negative numbers, just take the 2's complement as you would for an integer. This is done by complementing all the bits and adding 1 (Throw away the carry, if any)
.
When you are done, of course, you must divide the result by 65536 to get the proper scaling.
Regards,
Kral
|
|
| Back to top |
|
 |
Google AdSense

|
10 Feb 2009 23:45 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
Enlightenment
Joined: 26 Jul 2006 Posts: 44 Helped: 2 Location: 3rd Rock From Sun
|
11 Feb 2009 1:26 convert binary fraction to hexadecimal |
|
|
|
|
Tip: Read about fixed-point math.
http://en.wikipedia.org/wiki/Fixed-point_arithmetic
http://www.embedded.com/columns/15201575?_requestid=226315
|
|
| Back to top |
|
 |
xie.qiang
Joined: 19 Feb 2006 Posts: 20
|
12 Feb 2009 4:44 convert fixed point to hex |
|
|
|
|
| I think you need to konw what algorithm you want, either Fix-Point alogrithm or floating-point alogrithm, for fix-point, the above explaination is sufficient, but for floating-point, you need to convert the hex-reprensentation of your floating numbers, and again you need to designate in your assemble code that your hex nubmer is represent of floating numbers. I do not konw how to do this..
|
|
| Back to top |
|
 |