Converting Integer to any base

Discussion in 'Java' started by Dexter, Mar 20, 2008.

  1. Dexter

    Dexter Guest

    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/integer2decimal.html

    Hope it finds it use for someone facing the same problem

    Asad
    Dexter, Mar 20, 2008
    #1
    1. Advertising

  2. Dexter

    Roedy Green Guest

    On Thu, 20 Mar 2008 01:11:58 -0700 (PDT), Dexter
    <> 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
    Roedy Green, Mar 20, 2008
    #2
    1. Advertising

  3. Dexter <> 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/api/java/lang/Integer.html#toString(int, int)>

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

    /L
    --
    Lasse Reichstein Nielsen -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
    Lasse Reichstein Nielsen, Mar 20, 2008
    #3
  4. Dexter

    Dexter Guest

    On Mar 20, 6:12 pm, Lasse Reichstein Nielsen <> wrote:
    > Dexter <> 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/api/java/lang/Integer.html#toStri...., int)>
    >
    > Example source here:
    > <URL:http://www.docjar.com/html/api/java/lang/Integer.java.html>
    >
    > /L
    > --
    > Lasse Reichstein Nielsen  -  
    >  DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    >   'Faith without judgement merely degrades the spirit divine.'


    I am no expert.

    Asad
    Dexter, Mar 20, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    CType(x,Integer) vs. Integer.Parse(x)

    =?Utf-8?B?Sm9l?=, Feb 6, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    5,939
    =?Utf-8?B?RGF2aWQgQW50b24=?=
    Feb 7, 2006
  2. =?ISO-8859-1?Q?Thomas_Gagn=E9?=

    No Math.min(Integer, Integer)?

    =?ISO-8859-1?Q?Thomas_Gagn=E9?=, Jul 29, 2003, in forum: Java
    Replies:
    0
    Views:
    495
    =?ISO-8859-1?Q?Thomas_Gagn=E9?=
    Jul 29, 2003
  3. Roy J
    Replies:
    2
    Views:
    442
    Andrew Thompson
    Jul 11, 2004
  4. Sebastian Stelzer

    How do I add an Integer to another Integer?

    Sebastian Stelzer, Oct 14, 2004, in forum: Java
    Replies:
    2
    Views:
    481
    Yu SONG
    Oct 15, 2004
  5. Dexter

    Converting Integer to any base

    Dexter, Mar 20, 2008, in forum: C Programming
    Replies:
    1
    Views:
    324
    Flash Gordon
    Mar 20, 2008
Loading...

Share This Page