• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert Whole numbers to Hex
#6
(04-01-2011, 08:59 AM)Pack3t SynAck3r Wrote:
(04-01-2011, 01:00 AM)latch Wrote:
(03-01-2011, 09:24 PM)Drumm Wrote: It is possible to do this with some kind of library, but I wanted too challenge myself to learn how to convert Decimal to Hex in my mind.
It's rather simple tbh, I'll explain if somebody asks.

I'm impressed that you even care about hex.

I only code once or twice a month(my environment is not conducive to concentration) and read hex about that often. Even programmers don't use hex much anymore as far as I know. High level languages don't get that close to the machine.

Hex(base16) is still widely used, but mainly because it is a hell of a lot easier to write 0x9B6D than to write the binary(base2) equivalent of 1001101101101101. It is used generally in "lower" level languages such as C/C++ and ASM, although almost all languages allow for it. The programs' purpose will determine whether or not the inclusion of hex is necessary.
For example the program I have been working on recently steps through 512 bytes of raw data. The code I wrote is 90% operating on different hex values with regard to their position, value and significance. The 512 bytes if looked at as a whole would be called the MBR(master boot record) of a Windows NTFS volume. The program specifically analyzes bootkits (MBR rootkits) and in the short term allows for reverse engineering and disinfection. In the long run it is merely a piece of my master suite of software I have been working on since I was your age.

Although all numbers can be displayed in whatever base form you would like the relationship between hex and binary is more relevant than hex and decimal(base10.) If you are debugging a program you are generally going to need to be able to reference the memory address space your program is using. This is shown in hex. If you ever want to be able to find a flaw in the new ios you will have to understand how to reverse engineer it. This will leave you with a shit load of lines of assembly code with operators on hexadecimal values representing memory space and the processor register. If you ever hope to write a buffer overflow it is an exercise of pushing more data in a space of memory than the program is designed to handle in certain strategic places. It is necessary to write a program to find these strategic points, and to find out what opportunities these strategic points in turn offer you the ability to do. You will certainly be manipulating hexadecimal values if you ever get this far down the road.

Um yeah. Clearly I did not think my post through before I posted it. My excuse is that I posted it hastily, in my van, in the parking lot of a company I was borrowing internet from. When I read your post I could see code from memory that had hex in it. This very forum uses hex in the colors! Each place holder or digit represents a nybble or 4 bits or half a byte and it IS very easy to wrap your head around what the numbers are doing in hex. Truly decimal is more difficult to deal with and (BCD)binary coded decimal used in digital circuitry is a waste of resources- though necessary sometimes when displaying numbers to peoplemeat.
Yikes! I just betrayed my desire to be incorporeal!
Having long hair is great until you have to pull a footlong out of the dog's butt. flatank.blogspot.com
I. AM. LATCH.
  Reply


Messages In This Thread
Convert Whole numbers to Hex - by Drumm - 03-01-2011, 01:29 PM

Forum Jump: