I am wondering if someone could set me in the right direction with a problem I am working on. I am trying to do what the following C function does using only ARM assembly and bit manipulation:
int float2int(float x) {
return (int) x;
}
I have already coded the reverse of this (int2float) without many issues. Im just unsure of where to start with this new problem.
For example:
3 (int) = 0x40400000 (float)
0011 = 0 10000000 10000000000000000000000
Where 0 is the Sign Bit, 10000000 is the exponent, and 10000000000000000000000 is the mantissa/fraction.
Can someone simply point me in the right direction with this problem? Even a C pseudocode representation would be helpful. I know I need to extract the sign bit, extract the exponent and reverse the bias (127) and also extract the fraction but I just have no idea where to begin.
There is also the issue of if the float cannot be represented as an integer (because it overflows or is a NaN).
Any help would be appreciated!