Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

conversion of negative floating point number in binary using VHDL

I was literally stuck witha problem regarding the conversion of negative floating point number in binary and to write it in VHDL.For example the num is -0.8.when i convert it into binary it is like .11001100.since it is -ve i have to convert it into 2's complement and to provide the extra MSB bit.

My question is that how to represent it in VHDL without using that decimal point.Plz kindly help me in this regard.

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Floating point formats usually use a separate bit for the sign (so you have separate encodings for +0 and -0).

    You might be much better off using 'fixed point' arithmetic - where you multiply the FP numbers by a constant and then process the integer part (using 2's compliment integer arithmetic).
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If you don't use floating point, you'll most likely refer to a fixed point format with a specific number of fractional bits. You need to define the used format before converting to it.