aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Hex, Octal, converstions to Int?  Tricks anyone? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Hex, Octal, converstions to Int?  Tricks anyone?" Watch "Hex, Octal, converstions to Int?  Tricks anyone?" New topic
Author

Hex, Octal, converstions to Int? Tricks anyone?

Brett Swift
Ranch Hand

Joined: May 22, 2002
Posts: 61
My textbook just goes through literally 2 or 3 examples of each.
ie 010 = int 8.
and 0xf = int 15.
Does anyone have a trick to figure out the larger numbers? Maybe my brain is jello from studying too hard...cuz I can't seem to figure out a formula to convert larger Hex, and Octal numbers into an integer!
Thanks in advance! ! !
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
To convert from any abitrary base to base 10, you simply take each digit and multiply it with the proper power of two and sum these values. Take these examples:

If you need more help with this, do a search in this forum - I'm sure you'll find lots more samples.
Corey


SCJP Tipline, etc.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hex, Octal, converstions to Int? Tricks anyone?