Hexadecimal and Octal constants -- Help!

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Hexadecimal and Octal constants -- Help!

  1. #1
    Join Date
    Sep 2004

    Hexadecimal and Octal constants -- Help!

    I really don't understand this concept. My book explains this in a confusing fashion.

    How exactly does this system work? How does hex 0xff equal 255?

    Or oct 011 equal 9??

  2. #2
    Join Date
    Sep 2004
    Hexadecimal is a base 16 number scheme and Octal is a base 8 scheme. Therefore, F in hexadecimal is equal to 15 and 0xFF would be equal to 15 x 16 + 15 = 255. The octal number of 011 would be calculated as 1 * 8 + 1 = 9.

  3. #3
    Join Date
    Feb 2004
    if you had 16 fingers, you would probably count in base 16..

    in computers, we do count in base 16, cos it helps. we need some symbols to represent the count, and 0 to 9 do nicely for the first ten, but then what symbols do we use for the remaining six? rather than defining some new symbols, we just use A to F

    dont look at them as letters, look at them as symbols that link to a number of something.. put fifteen apples on a table, and then say "there are F apples there"

    think about how decimal things break down:

    is 2 * 10 * 10
    + 7 * 10
    + 5

    so the number 7FE is:
    7 * 16 * 16 +
    F * 16 +

    remembering that F means "fifteen" and E means fourteen

    -its a weird concept to get your head around, but just imagine that you grew up in a world where the base was different. at the moment, you run on base 10, because you have ten fingers, and you learn to count on your fingers. you understand in base 10, because its all there has ever been. so you must translate from base X to base 10.
    a bit like you speak english, and when you learn french, you learn the weird way they say things:
    "A quelle heure et il?" => "At what hour is he?"
    "J'ai deux heures moins le quart" => "I have 2 hours less a quarter"

    we say "What time is it?" "It's one forty five"
    so you start translating between english and french.. french people think in french, english people think in english. english people speaking french think in english and convert to french. after some years, they think in french too.
    normal people think in tens. computers think in 16s. new programmers think in tens and convert to 16s. oldtimers think in 16s
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center