Results 1 to 2 of 2

Thread: Base conversion

  1. #1
    NoobieCode is offline Senior Member
    Join Date
    Mar 2013
    Rep Power

    Default Base conversion

    Hello forum. I am confused. I am writing a method that takes in a int value and a base and from those two find the base number . For example: The method takes a number, say 342, and converts it to a base (any base).

    I understand the algorithm, cant fathom the code

    Heres what I know

    value % base = first digit starting from right
    (value/base) % base = second digit starting from the right
    (value/base^2)% base = third digit starting from right...

    ,... and so forth.

    I am not sure how to write this loop. I was thinking a while...I cant see this. Can some one help me better understand how to loop this? THanks in advance

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Base conversion

    Get some paper and pencil and go through the algorithm by hand. You should notice a repetitive pattern. Also, do this when converting decimal to decimal. It might make it easier to visualize.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Need some help with decimal to base conversion!!
    By chelsid7 in forum New To Java
    Replies: 1
    Last Post: 05-06-2013, 02:23 AM
  2. Replies: 2
    Last Post: 02-22-2013, 06:10 PM
  3. Base Conversion
    By javaman1 in forum New To Java
    Replies: 6
    Last Post: 12-10-2010, 07:32 PM
  4. base conversion (large)
    By billymac00 in forum New To Java
    Replies: 1
    Last Post: 04-07-2009, 05:56 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts