Search code examples
reverse-engineeringbinaryfiles

Figuring out how a number is represented in hex form


Currently trying to essentially reverse engineer a file format that is produced by a CNC machine when backing up programs on the machine so that i can read the programs on a standard PC. Have opened a few of the backup files created and can clearly see patterns of data such as the program name etc. which can be clearly seen in plaintext form. One thing i am struggling with is how numbers are represented in this.

for Example: the number '20' is represented in this file in hex form as '40 0D 03 00'.

More examples:

"-213.6287": "21 67 DF FF"

"-500.3366": "9A A7 B3 FF"

Any help with trying to figure out how these hex values make up those numbers?

Thanks


Solution

  • These numbers are stored as little-endian signed integers, as a count of ten-thousandths.

    for Example: the number '20' is represented in this file in hex form as '40 0D 03 00'.

    0x00030d40 = 200000.

    "-213.6287": "21 67 DF FF"

    0xffdf6721 = -2136287.

    "-500.3366": "9A A7 B3 FF"

    0xffb3a79a = -5003366.