Hexadecimal (2024)

Article Index
Hexadecimal
Without Counting
Hex For Data

Page 2 of 3

Without counting

Being able to count in hex is a great way to understand the how the system works but it isn't much use when you are confronted with a message such as

AX=AD45

or

Color=0xFF00AC

To really feel at home with hex you have to be able to understand it in a slightly different way. You certainly have to be able to convert hex to decimal and vice versa but there is something deeper.

First, though, how do you convert hex to decimal?

There are a number of standard algorithms that can be used to convert between different number bases but I have to admit that I prefer a more primitive approach. The place values used in hex are:

Hex1000100101
Decimal16*16*1616*16161
4096256161

and you can use these to work out the equivalent decimal value quite easily.

For example, AD45 is simply:

A*4096 + D*256 + 4*16 + 5*1

to express it in a mix of hex and decimal, or moving entirely to decimal:

10*4096 + 13*256 + 4*16 + 5*1

which works out to:

40960 + 3328 + 64 + 5

or

44357.

To convert from decimal to hex is just a little more complicated in that you have to discover how many lots of 4096, 256 and 16 there are in a number. For example, 44357 contains 10 lots of 4096 because:

44357/4096 = 10.83

The remainder, i.e.

44357-4096*10

is 3397 and this contains 13 lots of 256 because:

3397/256 = 13.27

and so on to discover that the remainder contains 4 lots of 16 and 5 units. Writing 10 lots of 4096, 13 lots of 256, 4 lots of 16 and 5 units in standard hex gives AD45.

Fortunately it isn't often that you have to convert decimal to hex!

Hexadecimal (1)

Why is hex useful?

So far, using hex for a number looks as if it might be some sort of intellectual game or something that examiners can use to set a good question. Programmers are, as a group, fairly lazy and you can bet that they wouldn't make use of something if it didn't make life easy.

There are two ways in which hex makes life easier.

The first is that it can be used to write down very large integers in a compact form.

For example, AD45 is shorter than its decimal equivalent 44357 and as values increase the difference in length becomes even more pronounced.

This `short form' is really only a minor benefit compared with the second reason why we use hex.

Hex values are closely related to binary values and powers of two.

For example, 1KByte of memory is 1024 bytes in decimal. If you address each memory location in decimal the address range is 0 to 1023. In hex 1KByte is 400 bytes and the address range is 0 to 3FF.

This is quite interesting but you begin to see the pay off when you look at the problem of addressing say 64KBytes which in decimal is 65536 but in hex is simply 10000 bytes. The equivalent addressing ranges are 0 to 65535 in decimal and 0 to FFFF in hex.

The following table shows how much simpler these commonly used values and ranges look in hex:

Memory sizes

BytesHexAddress range
16100 - F
2561000 - FF
1K4000 - 3FF
4K10000 - FFF
64K100000 - FFFF
1M1000000 - FFFFF
16M10000000 - FFFFFF

If you look at this table you will notice that 1KByte stands out like a sore thumb as not being a nice hex number. The reason is that 1KByte is a strange unit of memory that has received attention just because it is close to 1000 decimal, i.e. 1024 bytes . It is more natural for the size of memory to double at each step because adding an additional hardware addressing line allows you to work with twice as much memory. This is the reason that the numbers that keep on occurring are always powers of two and hex is particularly good at representing powers of two in a nice neat format.

Practical hex

Now you can begin to see why hex is used so much to report addresses and data. In the case of an address the hex form tells you immediately what area of memory is concerned.

For example, if an error message talks about location EF10 then you should be able to figure out that it is an address in the first 64K, somewhere close to the top.

To really make use of such information however you need to be able to use a debugger to look at that area of memory and step through it a chunk at a time.

Of course being able to do this sometimes means being able to perform hex arithmetic. Not many people are any good at adding and subtracting hex numbers so most debuggers will do this for you and Windows calculator has a hex mode. In the old days programmers, usually assembly language programmers, often had pocket hex calculators - yes a real calculator that worked in hex. Assembly language programmers thought in hex.

And yes I knew things had gone too far when I realized I'd just written a check for $FB.



Hexadecimal (2024)

FAQs

How to solve hexadecimal code? ›

Start with the right-most digit of your hex value. Multiply it by 160, that is: multiply by 1. In other words, leave it be, but keep that value off to the side. Remember to convert alphabetic hex values (A, B, C, D, E, and F) to their decimal equivalent (10, 11, 12, 13, 14, and 15).

How do you read hexadecimal easily? ›

Understand how the system works.

The hexadecimal color system is easy to understand, once you know how it works. The first two digits are the red value, the next two are the green value, and the last two are the blue value. Here are some examples: #FFFFFF is white, while #000000 is black.

How to remember hexadecimal table? ›

You don't have to memorize them, the only thing you have to know is that hexadecimal digits range from 0 to 9 and A to F (meaning 10 to 15) and that F is 1×2^3+1×2^2+1×2^1+1×2^0=8+4+2+1=15. So the hexadecimal A is the binary 1010 (meaning 1×2^3+0×2^2+1×2^1+0×2^0=10).

Why is there no 16 in hexadecimal? ›

Because there is no character to represent 16. Hexadecimal characters go from 0 to F (15). Since the F represents 15 the number FF is 255 because (15*16) + (15) = 255.

How do you say hello in hexadecimal? ›

So, "hello" would be : 68 65 6c 6c 6f 32 in HEX.

What is the hexadecimal system for dummies? ›

Out of many types of number representation techniques, the Hexadecimal number system is one having a value of base 16. So Hexadecimal numbers have 16 symbols or digital values, i.e 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. A, B, C, D, E, F are single bit representations of 10, 11, 12, 13, 14 and 15 respectively.

Is hexadecimal difficult? ›

The format of hex numbers is more compact than binary numbers because they can represent large binary numbers with fewer digits. As a result, they are easier to understand than long binary strings of 1s and 0s.

How to calculate hex code? ›

Summary – Reading HEX Color Codes

We use Base-16 to determine those values, from 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A(10), B(11), C(12), D(13), E(14), F(15). We always multiply the first number of each pair by 16, then add the two numbers together to get our R, G, or B value.

What is ffff in hexadecimal? ›

What is hex FFFF in decimal? Hexadecimal notation FFFF equals 65535 in decimal value. What is the decimal to hexadecimal formula? The decimal to hexadecimal conversion involves dividing the decimal number by 16 and noting the remainders, then assigning hexadecimal equivalents.

Why can't computers understand hexadecimal? ›

The computer doesn't understand hexadecimal digits. Machine code isn't really made of hexadecimal digits. Machine code is a set of binary patterns. Humans might ask to see a hexadecimal representation of the machine code, but that's just a representation.

Why 0x before hex? ›

To avoid confusion with decimal, octal or other numbering systems, hexadecimal numbers are sometimes written with a "h" after or "0x" before the number. For example, 63h and 0x63 mean 63 hexadecimal.

Why is 255 ff in hexadecimal? ›

Working with letters is a similar concept. For example, the value of FF is 255 because you multiply the value of F i.e 15 by 16, then you multiply the value of F i.e 15 by 1. Then add both the values together to get a single value i.e. 255. And the number 255 in hexadecimal colour code represents the bright red colour.

Is f 15 in hexadecimal? ›

F (in hexa) equal to 15 (and not 16). FF (in hexa) equal to 255.

What are the 16 digits of hexadecimal? ›

The hexadecimal number system is a type of number system, that has a base value equal to 16. It is also pronounced sometimes as 'hex'. Hexadecimal numbers are represented by only 16 symbols. These symbols or values are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. Each digit represents a decimal value.

How do you write hexadecimal in code? ›

Digits in hexadecimal use the standard symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 to represent the corresponding value, and use the first six letters of the alphabet to represent the values 10 through 15 (E.G: A, B, C, D, E, F). In programming, we prefix hexadecimal constants with 0x , with some exceptions.

Top Articles
LAANC | Aloft
CoverHound® | Insurance Learning Center |
Mybranch Becu
Katie Nickolaou Leaving
Jesus Calling December 1 2022
Coffman Memorial Union | U of M Bookstores
Teenbeautyfitness
Wfin Local News
Imbigswoo
Locate Td Bank Near Me
Zürich Stadion Letzigrund detailed interactive seating plan with seat & row numbers | Sitzplan Saalplan with Sitzplatz & Reihen Nummerierung
Wildflower1967
U/Apprenhensive_You8924
Walmart Double Point Days 2022
Midlife Crisis F95Zone
Roster Resource Orioles
St Maries Idaho Craigslist
Loves Employee Pay Stub
Vandymania Com Forums
Two Babies One Fox Full Comic Pdf
Wkow Weather Radar
Riversweeps Admin Login
Tire Plus Hunters Creek
Idle Skilling Ascension
Does Royal Honey Work For Erectile Dysfunction - SCOBES-AR
Craigslist Sf Garage Sales
Advance Auto Parts Stock Price | AAP Stock Quote, News, and History | Markets Insider
Homewatch Caregivers Salary
Mrstryst
Indiana Jones 5 Showtimes Near Jamaica Multiplex Cinemas
Kokomo Mugshots Busted
How to Get Into UCLA: Admissions Stats + Tips
Admissions - New York Conservatory for Dramatic Arts
Google Flights Orlando
Scarlet Maiden F95Zone
Cnp Tx Venmo
Gopher Hockey Forum
Emily Browning Fansite
Shoecarnival Com Careers
2024-09-13 | Iveda Solutions, Inc. Announces Reverse Stock Split to be Effective September 17, 2024; Publicly Traded Warrant Adjustment | NDAQ:IVDA | Press Release
Candise Yang Acupuncture
Squalicum Family Medicine
How To Get To Ultra Space Pixelmon
What is a lifetime maximum benefit? | healthinsurance.org
Rise Meadville Reviews
bot .com Project by super soph
Dlnet Deltanet
Missed Connections Dayton Ohio
Mike De Beer Twitter
Texas 4A Baseball
Varsity Competition Results 2022
Latest Posts
Article information

Author: Clemencia Bogisich Ret

Last Updated:

Views: 5568

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Clemencia Bogisich Ret

Birthday: 2001-07-17

Address: Suite 794 53887 Geri Spring, West Cristentown, KY 54855

Phone: +5934435460663

Job: Central Hospitality Director

Hobby: Yoga, Electronics, Rafting, Lockpicking, Inline skating, Puzzles, scrapbook

Introduction: My name is Clemencia Bogisich Ret, I am a super, outstanding, graceful, friendly, vast, comfortable, agreeable person who loves writing and wants to share my knowledge and understanding with you.