Results 1 to 2 of 2
Thread: help needed urgently
- 03-04-2009, 09:47 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 3
- Rep Power
- 0
help needed urgently
hi friends,
i'm trying to write a program that converts decimal value into any (binary,octal and hexa decimal)
i'm printing the result but i coudn't convert hexa decimal value
please help me
here is my code
public class decx
{
public static void main(String args[])
{
String output=decx.decToBase(28,2);
String output1=decx.decToBase(234,8);
String output2=decx.decToBase(2989,16);
System.out.println(output);
System.out.println(output1);
System.out.println(output2);
}
static String decToBase(int n,int radix)
{
String str=" ";
String str1="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int i;
int rem;
while(n!=0)
{
i=n/radix;
rem=n%radix;
System.out.println(rem);
n=i;
if(rem<=9)
{
str=str+rem;
}
else
{
rem=str1.charAt(rem);
str=str+rem;
}
}
return str;
}
}
- 03-04-2009, 10:00 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Can you tell me the way you try to convert decimal to hexadecimal values in your code.
Similar Threads
-
JSP (urgently)
By G.Ajay Kumar in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 02-19-2009, 05:43 AM -
Project Manager/lead, Techlead (j2ee) Wanted Urgently For An Mnc!!
By vjay104 in forum Jobs OfferedReplies: 2Last Post: 01-27-2009, 03:35 PM -
Help!urgently please
By kevN in forum AWT / SwingReplies: 10Last Post: 01-09-2009, 05:37 PM -
Help needed, urgently!
By Emfy in forum New To JavaReplies: 5Last Post: 12-27-2008, 03:06 PM -
please help urgently
By ananas7777 in forum New To JavaReplies: 1Last Post: 12-22-2007, 02:48 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks