HEX2DEC


Converts a hexadecimal number to decimal.

Syntax:

HEX2DEC(hexadecimalnumber)


returns a (decimal) number, given hexadecimalnumber, which may be text, or a number (taken to be hexadecimal although it is not).

hexadecimalnumber may have up to ten digits in two's complement representation; positive numbers are 0 to 7FFFFFFFFF (representing 0 to 239-1 decimal) and negative numbers FFFFFFFFFF to 8000000000 (representing -1 to -239 decimal).

Example:

HEX2DEC("1E")

returns 30 as a (decimal) number.

HEX2DEC("FFFFFFFFFE")

returns -2 as a (decimal) number.

HEX2DEC($B$10)

returns the contents of cell B10 as a (decimal) number.

HEX2DEC(20)

returns 32 as a (decimal) number. The number 20 is read as hexadecimal. This is not recommend since changing the parameter to 1F without double quotes will result in HEX2DEC converting the parameter to F1 and doing a cell lookup.


Application:

Converting a Web Color Code


Imagine you're a web developer working with a design team. They give you a specific color for a button, and the color is provided as a hexadecimal code: #A0D2E4. You need to understand the exact intensity of each color component (Red, Green, Blue) on a scale from 0 to 255 to use it in a different format, like an RGB value.


This is where you would use the HEX2DEC concept. The hexadecimal code #A0D2E4 is broken down as follows:

  • Red: A0
  • Green: D2
  • Blue: E4


Now, let's use the HEX2DEC function on each part.


Step 1: Convert Red (A0)

A hexadecimal number is a positional system, just like decimal. Each position is a power of 16.

  • A0 = (A * 16^1) + (0 * 16^0)
  • In hexadecimal, 'A' is equivalent to the decimal number 10.
  • A0 = (10 * 16) + (0 * 1)
  • A0 = 160 + 0
  • A0 = 160


Step 2: Convert Green (D2)

  • D2 = (D * 16^1) + (2 * 16^0)
  • In hexadecimal, 'D' is equivalent to the decimal number 13.
  • D2 = (13 * 16) + (2 * 1)
  • D2 = 208 + 2
  • D2 = 210


Step 3: Convert Blue (E4)

  • E4 = (E * 16^1) + (4 * 16^0)
  • In hexadecimal, 'E' is equivalent to the decimal number 14.
  • E4 = (14 * 16) + (4 * 1)
  • E4 = 224 + 4
  • E4 = 228

Result Table

Here is the table summarizing the conversions:

Component

Hexadecimal (Input to HEX2DEC)

Calculation (HEX2DEC Function)

Decimal (Output)

A
B
C
D
1
Red
A0
(10 * 16^1) + (0 * 16^0)
160
2
Green
D2
(13 * 16^1) + (2 * 16^0)
210
3
Blue
E4
(14 * 16^1) + (4 * 16^0)
228

So, the hexadecimal color code #A0D2E4 is equivalent to the RGB value (160, 210, 228). The HEX2DEC function allows us to understand the precise intensity of each color channel, which is crucial for various applications beyond web design, such as graphics programming, video editing, and digital art.





This page is protected by Google reCAPTCHA. Privacy - Terms.
 
Built using Zapof