aspose file tools
The moose likes Beginning Java and the fly likes Couple quick questions about octel and hex notation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Couple quick questions about octel and hex notation" Watch "Couple quick questions about octel and hex notation" New topic
Author

Couple quick questions about octel and hex notation

David Miranda
Ranch Hand

Joined: Mar 14, 2005
Posts: 34
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
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24081
    
  15

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.


[Jess in Action][AskingGoodQuestions]
David Miranda
Ranch Hand

Joined: Mar 14, 2005
Posts: 34
Great, thanks!
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 952
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Couple quick questions about octel and hex notation
 
Similar Threads
Base conversion
char c='\101'; ..?
A question about Dan Mock Exam Chapter 2 Exam 2
Hexadecimal
Conversion