electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

how to convert floating numbers in hex to use in assembly?


Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital Signal Processing -> how to convert floating numbers in hex to use in assembly?
Author Message
smartshashi



Joined: 11 Aug 2004
Posts: 63


Post10 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


Post10 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
Google Adsense




Post10 Feb 2009 23:45   

Ads




Back to top
Enlightenment



Joined: 26 Jul 2006
Posts: 44
Helped: 2
Location: 3rd Rock From Sun


Post11 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


Post12 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
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital Signal Processing -> how to convert floating numbers in hex to use in assembly?
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
convert hex codes to assembly (5)
How to convert Hex -> Asm -> C (4)
how to convert c code to hex (9)
HOw to convert float32 to hex? (7)
How to convert from hex to std_logic? (2)
How to convert C -> Asm -> Hex {pic} (1)
PIC hex to assembly or hex to C converter (7)
how to convert bitmap to intel hex format (3)
How can I convert into Hex following Code (1)
how to convert binary to BCD or decimal in assembly (4)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS