Forum Discussion
Altera_Forum
Honored Contributor
14 years agoSingle Precision Floating Point
Hi All, I'm trying to outsource an equation using floating point variables to another system block within my design. In my Nios code, the two variables (say, x and y) are defined as floats...
Altera_Forum
Honored Contributor
14 years agoDo you mean that the value is being written as an integer?
That will mean that somewhere in the C you are casting (maybe implicitly) the 'float' to an 'int' and the relevant conversion function is being called. You need to use define your IO location as 'float *'. It might be good enough to define a union of float and int and copy the data value through it (you do need to have a variable of the union type, just using casts - *(int *)&float_variable - isn't required to force the compiler to do the reads and writes in the correct order).