Figuring out how a number is represented in hex form












0















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










share|improve this question


















  • 1





    If I was you I'd keep reversing - there is no way that 20 decimal has any direct correlation with 40 0D 03 00 hex. So maybe it isn't storing decimal amounts directly, maybe it's a vector or something else instead?

    – slugster
    Jan 19 at 23:43
















0















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










share|improve this question


















  • 1





    If I was you I'd keep reversing - there is no way that 20 decimal has any direct correlation with 40 0D 03 00 hex. So maybe it isn't storing decimal amounts directly, maybe it's a vector or something else instead?

    – slugster
    Jan 19 at 23:43














0












0








0








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










share|improve this question














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







reverse-engineering binaryfiles






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 19 at 23:38









jaypjayp

31




31








  • 1





    If I was you I'd keep reversing - there is no way that 20 decimal has any direct correlation with 40 0D 03 00 hex. So maybe it isn't storing decimal amounts directly, maybe it's a vector or something else instead?

    – slugster
    Jan 19 at 23:43














  • 1





    If I was you I'd keep reversing - there is no way that 20 decimal has any direct correlation with 40 0D 03 00 hex. So maybe it isn't storing decimal amounts directly, maybe it's a vector or something else instead?

    – slugster
    Jan 19 at 23:43








1




1





If I was you I'd keep reversing - there is no way that 20 decimal has any direct correlation with 40 0D 03 00 hex. So maybe it isn't storing decimal amounts directly, maybe it's a vector or something else instead?

– slugster
Jan 19 at 23:43





If I was you I'd keep reversing - there is no way that 20 decimal has any direct correlation with 40 0D 03 00 hex. So maybe it isn't storing decimal amounts directly, maybe it's a vector or something else instead?

– slugster
Jan 19 at 23:43












1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer
























  • Just realised this as i was analysising the hex values. How is the location of the decimal point decided in this though?

    – jayp
    Jan 20 at 0:00











  • Based on the examples you've given, the scaling factor (of 10,000) may just be inherent to the format, or the device.

    – duskwuff
    Jan 20 at 0:06











  • Yep seems like you're right! just had a scan through the rest of the file and you are right by saying its inherent to the format :) thank you so much for the help!

    – jayp
    Jan 20 at 0:29













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54272300%2ffiguring-out-how-a-number-is-represented-in-hex-form%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














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.






share|improve this answer
























  • Just realised this as i was analysising the hex values. How is the location of the decimal point decided in this though?

    – jayp
    Jan 20 at 0:00











  • Based on the examples you've given, the scaling factor (of 10,000) may just be inherent to the format, or the device.

    – duskwuff
    Jan 20 at 0:06











  • Yep seems like you're right! just had a scan through the rest of the file and you are right by saying its inherent to the format :) thank you so much for the help!

    – jayp
    Jan 20 at 0:29


















1














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.






share|improve this answer
























  • Just realised this as i was analysising the hex values. How is the location of the decimal point decided in this though?

    – jayp
    Jan 20 at 0:00











  • Based on the examples you've given, the scaling factor (of 10,000) may just be inherent to the format, or the device.

    – duskwuff
    Jan 20 at 0:06











  • Yep seems like you're right! just had a scan through the rest of the file and you are right by saying its inherent to the format :) thank you so much for the help!

    – jayp
    Jan 20 at 0:29
















1












1








1







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 19 at 23:50









duskwuffduskwuff

147k19177233




147k19177233













  • Just realised this as i was analysising the hex values. How is the location of the decimal point decided in this though?

    – jayp
    Jan 20 at 0:00











  • Based on the examples you've given, the scaling factor (of 10,000) may just be inherent to the format, or the device.

    – duskwuff
    Jan 20 at 0:06











  • Yep seems like you're right! just had a scan through the rest of the file and you are right by saying its inherent to the format :) thank you so much for the help!

    – jayp
    Jan 20 at 0:29





















  • Just realised this as i was analysising the hex values. How is the location of the decimal point decided in this though?

    – jayp
    Jan 20 at 0:00











  • Based on the examples you've given, the scaling factor (of 10,000) may just be inherent to the format, or the device.

    – duskwuff
    Jan 20 at 0:06











  • Yep seems like you're right! just had a scan through the rest of the file and you are right by saying its inherent to the format :) thank you so much for the help!

    – jayp
    Jan 20 at 0:29



















Just realised this as i was analysising the hex values. How is the location of the decimal point decided in this though?

– jayp
Jan 20 at 0:00





Just realised this as i was analysising the hex values. How is the location of the decimal point decided in this though?

– jayp
Jan 20 at 0:00













Based on the examples you've given, the scaling factor (of 10,000) may just be inherent to the format, or the device.

– duskwuff
Jan 20 at 0:06





Based on the examples you've given, the scaling factor (of 10,000) may just be inherent to the format, or the device.

– duskwuff
Jan 20 at 0:06













Yep seems like you're right! just had a scan through the rest of the file and you are right by saying its inherent to the format :) thank you so much for the help!

– jayp
Jan 20 at 0:29







Yep seems like you're right! just had a scan through the rest of the file and you are right by saying its inherent to the format :) thank you so much for the help!

– jayp
Jan 20 at 0:29




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54272300%2ffiguring-out-how-a-number-is-represented-in-hex-form%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Callistus III

Plistias Cous

Index Sanctorum