• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Couple quick questions about octel and hex notation

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Im trying to understand what the '0x' in lets say 0x0F stands for...

Does the '0x' just stand for 'this is hex'?

Also...

Lets say we have a number '010'...this is octel. Is putting a '0' in front of a number the only way to signify that a number is octel?

Thanks!

Dave
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David Miranda:

Does the '0x' just stand for 'this is hex'?



Yes, that's all.


Lets say we have a number '010'...this is octel. Is putting a '0' in front of a number the only way to signify that a number is octel?



Yes.
 
David Miranda
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great, thanks!
 
Bartender
Posts: 1205
22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simulpost! Oh well, I'll leave this here for the joke at the end if nothing else.
-------------------
Yes, 0x or 0X means this is a hexadecimal number.
And yes, just a leading 0 is the only way to make an octal integer contstant.

0x0c == 014 == 12

The thing that trips many people up is using leading zeros to make columns line up:



formatDate(CHRISTMAS) returns "12/25"
formatDate(HALLOWEEN) returns "10/30"
but formatDate(GROUNDHOG) returns "1/30"

The final static declarations should have been...


But octal and hex are handy for defining bits. Compare...


to...



Ryan


P.S. This talk of holidays reminds me of a riddle:

Why do programmers get Halloween and Christmas mixed up?







Because 31 Oct = 25 Dec
[ April 15, 2005: Message edited by: Ryan McGuire ]
 
This tiny ad is suggesting that maybe she should go play in traffic.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic