I have the following code snippet running on a MicroBlaze processor with Floating Point enabled:
However, the result is as follows:
What is the cause of this?
There are two errors in the above code:
1. The function xil_printf() does not support printing of floating point numbers. You will need to use the printf statement to print floating numbers.
Please refer to page 6 of the OS and Libraries collection document:
2. %x specifier only converts integers to hex. It does not work with floating point numbers.
To work around this, take the address of the float, cast the pointer to an integer pointer (which has no effect on the bit pattern of the data), and then dereference it so that the data is interpreted as an integer but without changing the bit pattern.
Therefore, the above code should be modified as follows:
The result will be as follows: