Home > Back-end >  Turn the decimal hexadecimal array
Turn the decimal hexadecimal array

Time:12-18

Have a 4 bytes of data hexadecimal array, {0 x1b, 0 xfe, 0 x7f, 0 x3f},
in python codeX1b
 databuf=[0, 0 xfe, 0 x7f, 0 x3f] 
,0,0,0 Quat=[0]
Buffer=struct. Pack (' 4 b '* databuf)
Quat [0]=struct. Unpack (' & lt; F ', buffer) [0]

Translate the result is [0.9999710917472839, 0, 0, 0], now I want to use c + + language is converted to a decimal

CodePudding user response:

The representation of the data is different, use different data types to explain the same secondary system code, the results are different

CodePudding user response:

#include
Int main ()
{
Int I, a, [4].//declare a array,
for(i=0; i<4. I++)
{the scanf (" % x ", & amp; A [I]); }//for statement input
for(i=0; i<4. I++)
{printf (" % d ", a [I]); }//for statement input
return 0;
}
  • Related