• Post Reply Bookmark Topic Watch Topic
  • New Topic

conversions  RSS feed

 
cybel sheriden
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
can i get to know fast conversion of a no from oct or hex to deci,i usually do it by converting it to binary and then to deci.....is there a faster way.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the Integer class. It can convert decimal numbers to octal and hexadecimal.
 
cybel sheriden
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
char c1 = 064770;
char c2= 0xbeef;

to check if above declaration is legal or not in the exam i need to convert it into decimal form to make sure it is in the range of character(0- 65535).
so for that i need to do fast conversion manually.
 
Horatio Westock
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I understand this completely. Can you provide some more pseudo code for what you are trying to do?
 
cybel sheriden
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
char c1 = 064770;
char c2= 0xbeef;
i want to convert 064770 & 0xbeef (manually)to decimal equvalent so tht i can check if it falls in the char range(0 - 65535).

i usually do it by converting it to binary and then to decimal which takes a bit of time ,i was wondering if there was a faster techniqu to do so.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!