Multiplying by p32
is equivalent to a left shift by 32 bits. It also results in a type conversion for the product (from int
to double
), as well as for the sum. This way you can essentially keep 64-bit int
s in the buffer and convert them to double
s when required.
Fixed point to Floating point
Question
I have the following code, I have just copied some data from external RAM to the MCU into a buffer called "data"
double p32 = 4.294967296e+009; /// equals to 2^32 in decimal notation
int32_t longhigh;
uint32_t longlow;
offset = mapdata(); //Points to the data I want, 55 bit fixed point on HW
longhigh = data[2*offset+1]; //Gets upperpart of data
longlow = data[2*offset]; //Gets lower part
double floating = (longhigh*p32 + longlow); // What is this doing? How does it work?
Can someone explain that last line of code for me? Why are we multiplying by p32? Thanks.
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow