I have a union, that is 8 fields of uint8, 2 fields of int32, or one int64.
I am trying to save an array of 8 values there: 0, 0, 0, 1, 0, 0, 0, 1
There is a bug in the software that I am trying to solve unfortunately, I don't understand the binary representation of this array.
My union:
union {
uint8_t u08[8];
uint32_t u32[2];
uint64_t u64;
} data;
My debugger output:
Name : u08
Details:"\0\0\0\001\0\0\0\001"
Default:0x4001e6a0 <ucHeap+66948>
Decimal:1073866400
Hex:0x4001e6a0
Binary:1000000000000011110011010100000
Octal:010000363240
Name : u32
Details:{1, 1}
Default:0x4001e6a0 <ucHeap+66948>
Decimal:1073866400
Hex:0x4001e6a0
Binary:1000000000000011110011010100000
Octal:010000363240
Name : u64
Details:4294967297
Default:4294967297
Decimal:4294967297
Hex:0x100000001
Binary:100000000000000000000000000000001
Octal:040000000001
My questions are:
- why does a u64 have a different value than the others? as far as I understand, c saves space only for one variable of a union to store the value.
- what does this binary representation of the uint8 array mean? Even if it was ASCII (which it isn't, as I am sending direct values, not chars), then '0' is 110000 and '1' is 110001
I'm using MPC5748G from NXP with S32DS (eclipse based IDE) for the debugging.
u08it looks as though the output foru64is the only correct one.