Forum Discussion

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

Long to Float

Hi,

I have a custom instruction which returns a float, but NIOS seems to grab this and treat it like a long, converted to float (if that makes sense)

# include "system.h"

int main (void)

{

float c = ALT_CI_IEEE_FPADD(a,http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/cool.gif ;

printf("Answer = %f", c);

return 0;

}

I get 0x40490fda returned by my CI, but c is printed as 1078530010 (that number!) how do I cast it as a float so I get 3.1415926 back?

Regards,

Steve.

3 Replies

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

    I could of swore I saw something about it not returning floating point data, but I may not have had my 6 cups of coffee before reading that.

    I would use the hack that James suggested myself.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks James,

    Worked a treat! - if you want to see it all in action go to IP downloads there is a FP add and mult with CI project for download.

    Regards,

    Steve.