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
reverse-engineering binaryfiles
add a comment |
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
1
If I was you I'd keep reversing - there is no way that20decimal has any direct correlation with40 0D 03 00hex. So maybe it isn't storing decimal amounts directly, maybe it's a vector or something else instead?
– slugster
Jan 19 at 23:43
add a comment |
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
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
reverse-engineering binaryfiles
asked Jan 19 at 23:38
jaypjayp
31
31
1
If I was you I'd keep reversing - there is no way that20decimal has any direct correlation with40 0D 03 00hex. So maybe it isn't storing decimal amounts directly, maybe it's a vector or something else instead?
– slugster
Jan 19 at 23:43
add a comment |
1
If I was you I'd keep reversing - there is no way that20decimal has any direct correlation with40 0D 03 00hex. 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
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
If I was you I'd keep reversing - there is no way that
20decimal has any direct correlation with40 0D 03 00hex. So maybe it isn't storing decimal amounts directly, maybe it's a vector or something else instead?– slugster
Jan 19 at 23:43