Re: hexidecimal

by Noone Special <pfarabee(at)indy.net>

 Date:  Thu, 5 Feb 1998 18:55:55 -0500 (EST)
 To:  Steve Mai <smai(at)plato.agricola.umn.edu>
 Cc:  hwg-graphics(at)hwg.org
 In-Reply-To: 
  todo: View Thread, Original
> Greetings,
> 
> Most hexidecimal colors I see use pairs: #ffffcc
> 
> Can I use this hexidecimal color:  #fffff1  ?
Yes
hexidecimal simply means base 16

base 10 uses 10 digits (0,1,2,3,4,5,6,7,8,9)
base 16 uses 16 digits (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)
base 8 (octal) uses 8 digits (0,1,2,3,4,5,6,7)
base 2 (binary) uses 2 digits (0,1)

To understand how they relate to each other, we must first look at the
representation of numbers in general.
Take the decimal number 1,345 for instance
broken down into digits, we get
1x1000 + 3x100 + 4x10 + 5
or, more exactly:
1x(10^3) + 3x(10^2) + 4x(10^1) + 5x(10^0)
or, in terms of base:
1x(base^3) + 3x(base^2) + 4x(base^1) + 5x(base^0)

So if 1345 were an octal number, it would represent:
1x(8^3) + 3x(8^2) + 4x(8^1) + 5(8^0)
or:
1x(512) + 3x(64) + 4x(8) + 5(1) = 512 + 192 + 32 + 5 = 741 (decimal)

if we then wanted to show that in hexidecimal, we could fairly easily by
figuring out how many of each (base^x) can fit into the number
16^3 = 4096
16^2 = 256
16^1 = 16
16^0 = 1

Since 4096 cannot fit into 741, we can zero It's place out..
0

741/256 = 2.8945 (round down) = 2
02
741 - (2*256) = 741 - 512 = 229
229/16 = 14.3125 (round down) = 14 (E in hex)
02E
229 - (14*16) = 229 - 224 = 5
5/1 = 5
02E5

Anyway.. hex numbers are just decimal numbers in disguize, so yes, you can
use any RGB code in hex that you can in decimal... that is each position
can hold any number from 0 to 255 (00 - FF in hex)

> I realize that it is not "browser-safe."  A 256 color monitor will default
> to white.  But it is a nice off-white, and transparent gifs will match
This is not correct.  Depending on settings, the color will either default
to white or be dithered to match the color you set.. the dithering is
usually quite ugly.

> My basic question is: Do I have to use character pairs (ff, CC, 00, etc.)
> in my hex color choices?
No :)

Pat

HWG: hwg-graphics mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.