Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

Posted on 2014-03-20
Medium Priority
291 Views
I took a output like in hexadecimal  (0xCF0400000100) and I want to convert it to a file and page address..according to a book I read, it says ""In hexadecimal notation,
each set of two hexadecimal digits represents a byte. I first had to swap the bytes to get
00 01 00 00 04 CF"" so I could not understand how it wrote 0xCF0400000100 as 00 01 00 00 04 CF...I think it converted a hex to binary so  is that possible?. if yes,could you please explain as detail?
0
Question by:TRocex
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 3

Expert Comment

ID: 39941744
Decimal:

Every digit is between 0 and 9 as in 01234567890 (10 different choices)
how to get the value from decimal number?
23465

5*1
6*10
4*10*10
3*10*10*10
etc

Hex:

Every "digit" is between 0 and F as in 01234567890ABCDEF (16 choices)
the value from hex number:

F3A5
5*1
A(10)*16
3*16*16
F(15)*16*16*16
etc

Binary:

every digit is between 0 and 1 as in 01 (2 digits)

value from binary number:
011001
1*1
0*2
0*2*2
1*2*2*2
1*2*2*2*2

etc

thus generalized:

digit(position)*base^position
where positon starts with 0 at rightmost place
base is 10 for decimal, 16 for hex, 2 for binary, can be anything

See here for automatic conversion, playing -> understanding:
0

Author Comment

ID: 39941804
many thanks I agree with you but the thing what I dont understand, In hexadecimal notation,
how the hex value 0xCF0400000100 can be written as 00 01 00 00 04 CF.. because the book says " each set of two hexadecimal digits represents a byte. I first had to swap the bytes to get
00 01 00 00 04 CF"  could you please explain that me?
0

LVL 3

Expert Comment

ID: 39941844
1. googling the number yields some results from MS SQL 2008.

the 0x is not part of the value
As long as you keep track of how you represent the serie you can of course write them in any sequence you want.

as in

10 45 67 87 23
(10,45,67,87,23)
1045678723

or

23
87
67
45
10

or

23 87 67 45 10

http://tinyurl.com/pvmospy
0

LVL 3

Assisted Solution

cristiantm earned 900 total points
ID: 39941993
The byte order thing, that is your question, looks like an endianess thing. Some systems are bigendian, that is, the most significant byte comes first, and others are little endian, when the less significant comes first.

So you are taking the value 0xCF0400000100 and putting it on on memory as little endian data, that is, in an "reversed" order.

This might help:
http://en.wikipedia.org/wiki/Endianness
0

LVL 37

Accepted Solution

TommySzalapski earned 600 total points
ID: 39942966
Yes. The byte order swapping is just due to the endianness of the system. The (little endian) system will store the number with the smallest byte first (kind of like if we wrote decimal numbers backwards). This is to make certain operations faster (since the first byte it sees is always the "ones" byte). When it displays the number for a human to read, though, it flips the order because that's how we are accustomed to reading numbers (with the "ones" place on the far right). What makes it confusing perhaps is that it swaps the bytes, not the hex digits.

Note that nothing is being "converted to binary." It's already in binary in the computer. Hexadecimal is just a convenient way of displaying the binary byte values to us humans. But two hex digits make one byte, so any time you see hex, think of the pairs of characters as inseparable. Putting spaces between them as you did is very helpful.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
###### Suggested Courses
Course of the Month7 days, 1 hour left to enroll