Forum Discussion

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

Two's Complement and Floating Point

Hello,

I have a range of integer values coming into my system in a two's complement format (positive and negative values).

I run these through the altfp_convert module to make these integers floating point values. I do various mathematical operations with them, using other altfp modules.

At the end, I use the altfp_convert to return the floating point to an integer to be written out.

I wanted to confirm that this conversion does not create a two's complement number, but a signed integer instead.

I require a two's complement format to send out, and I wanted to make sure that I would have to change the output of the altfp_convert module.

Thanks!

3 Replies

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

    The output is a 2s compliment number - 2s compliment is a signed format - ie. MSB tells you the sign.

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

    Sure, I've just noticed that I don't see the leading ones that I'd expect in a negative two's complement number.

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

    Then I suspect the output is always +ve

    Is there any reason you're using floating point? it's very costly to implement in terms of logic and latency. Fixed point is much cheaper.