Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Converting Integer to any base

Reply
Thread Tools

Converting Integer to any base

 
 
Dexter
Guest
Posts: n/a
 
      03-20-2008
Recently on a coding test , I was given a problem to write a program
that converts an integer to any given base between 2 and 16
(inclusive). I had written it in C# as this code is available to
viewers at


http://www.thinkanddone.com/prog/cs/...r2decimal.html

Hope it finds it use for someone facing the same problem

Asad
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      03-20-2008
On Thu, 20 Mar 2008 01:11:58 -0700 (PDT), Dexter
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone who
said :

>Recently on a coding test , I was given a problem to write a program
>that converts an integer to any given base between 2 and 16
>(inclusive). I had written it in C# as this code is available to
>viewers at


the code is built in to java. See
http://mindprod.com/jgloss/radix.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      03-20-2008
Dexter <(E-Mail Removed)> writes:

> Recently on a coding test , I was given a problem to write a program
> that converts an integer to any given base between 2 and 16
> (inclusive).

....
> Hope it finds it use for someone facing the same problem


I would recommend anyone with the same problem to think it over
and find their own solution. And anyone who only needs to convery,
not write a program to convert, to use the one built into the
language. It was made by experts.

It can be done *much* shorter than what you have done.
<URL:http://java.sun.com/j2se/1.5.0/docs/...l#toString(int, int)>

Example source here:
<URL:http://www.docjar.com/html/api/java/lang/Integer.java.html>

/L
--
Lasse Reichstein Nielsen - http://www.velocityreviews.com/forums/(E-Mail Removed)
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
Dexter
Guest
Posts: n/a
 
      03-20-2008
On Mar 20, 6:12*pm, Lasse Reichstein Nielsen <(E-Mail Removed)> wrote:
> Dexter <(E-Mail Removed)> writes:
> > Recently on a coding test , I was given a problem to write a program
> > that converts an integer to any given base between 2 and 16
> > (inclusive).

> ...
> > Hope it finds it use for someone facing the same problem

>
> I would recommend anyone with the same problem to think it over
> and find their own solution. And anyone who only needs to convery,
> not write a program to convert, to use the one built into the
> language. It was made by experts.
>
> It can be done *much* shorter than what you have done.
> <URL:http://java.sun.com/j2se/1.5.0/docs/...er.html#toStri...., int)>
>
> Example source here:
> <URL:http://www.docjar.com/html/api/java/lang/Integer.java.html>
>
> /L
> --
> Lasse Reichstein Nielsen *- *(E-Mail Removed)
> *DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
> * 'Faith without judgement merely degrades the spirit divine.'


I am no expert.

Asad
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Integer to any base Dexter C Programming 1 03-20-2008 06:07 PM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM
CType(x,Integer) vs. Integer.Parse(x) =?Utf-8?B?Sm9l?= ASP .Net 7 02-07-2006 02:30 AM
converting decimal to any base Roy J Java 2 07-11-2004 08:02 AM
No Math.min(Integer, Integer)? =?ISO-8859-1?Q?Thomas_Gagn=E9?= Java 0 07-29-2003 07:46 PM



Advertisments