Continue to Site

Welcome to EDAboard.com

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.

techniques to convert floating point to fixxedpoint

Status
Not open for further replies.

fireblade

Newbie level 6
Joined
Nov 1, 2006
Messages
13
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,356
what are the techniques to convert Floating point numbers to Fixed Point numbers.
 

It depends whether You can or cannot use floating point operations.
If You can do that, simply multiply the floating point value by 2^(number_of_fractional_bits) and convert the result to integer. In C there's a libm function ldexp() as far as I remember, which provides fast multiplication of floating point numbers by powers of two. It works by manipulating number's exponent value directly.

If You want to do this without messing with floating point math, just extract the mantisa, put '1' bit on the left, shift the number left or right according to it's exponent, and finaly multiply it with 1 or -1 depending on sign bit.
To be more precise, if Your mantisa length is M bits, e.g 23 for single precision ieee floating point numbers (24 bits with 'hidden 1', for double precision - ask google, and You have F fractional bits in Your fixed point numbers, then You need to shift the mantisa (with '1' as MSb included) (M - F) bits to the right, if (M-F) is negative, then You need to shift it to the left.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top