You have the values, 0x40, 0x7e, 0xa7, 0xf2, in the order for a big-endian system, but your system is little-endian. They need to be reversed.
Directly accessing the bytes that represent objects is generally not portable between different systems. The order in which bytes appear in the representation is just one of the differences that may occur.