I understood how typecast explained in the help file in the Matlab. But can't cope for my result. I tried to typecast a 3x4 matrix as follow.
A= -0.0022 -87.8788 -96.2848 -96.9586
0.9891 -52.9250 -52.7722 -52.7780
0.1473 -4.8680 -6.0184 -5.9894
ANS = typecast(A(:), 'uint16');
Then ANS vector becomes
ANS=65304
47886
13518
16253
55853
15894
49650
49839
45875
49747
50835
49307
37329
49856
5820
49747
38546
49344
60110
49857
7340
49747
43369
49343
That means -0.0022 have two 16 bits values of 65304 and 47886. How is it calculated? Then how can I implement in C++? In C++, I implemented like
float f = -0.0022;
unsigned short a = static_cast<unsigned int>(f);
unsigned short b = static_cast<unsigned int>(f)>>16;
I can't have a and b as 65304 and 47886.