Results 1 to 9 of 9

Thread: changing base

  1. #1

    Default changing base

    i am looking to convert base 10 numbers into base 3. i know there are functions to move between 2, 8, 10 and 16 but can excel handle base 3.

  2. #2
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    73,092

    Default Re: changing base

    Isn't it?

    =10*INT(A1/3)+MOD(A1,3)

    where A1 contains the base 10 number you want to convert.

  3. #3

    Default Re: changing base

    works up to 8, but 9 should be 100 in base 3. your formula returns 30, which is illegal in base 3

  4. #4

    Default Re: changing base

    Quote Originally Posted by lordrom
    works up to 8, but 9 should be 100 in base 3. your formula returns 30, which is illegal in base 3
    Morefunc add-in has an function CHBASE, you might find helpful

    ******** ******************** ************************************************************************>
    Microsoft Excel - Book1___Running: xl2002 XP : OS = Windows XP
    File Edit View Insert Options Tools Data Window Help About
    =

    A
    B
    C
    D
    1
    1009
    Sheet1

    [HtmlMaker light Ver1.10] To see the formula in the cells just click on the cells hyperlink or click the Name box
    PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.

  5. #5

    Default Re: changing base

    exactly what i'm after

    cheers


    now, where do i find morefunc? i trust it will cost?

  6. #6

    Default Re: changing base

    Quote Originally Posted by lordrom
    exactly what i'm after

    cheers


    now, where do i find morefunc? i trust it will cost?
    Actually it's FREE, there's a add-in link somewhere

    http://216.92.17.166/board2/viewtopic.php?t=49750

  7. #7
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    73,092

    Default Re: changing base

    Quote Originally Posted by lordrom
    works up to 8, but 9 should be 100 in base 3. your formula returns 30, which is illegal in base 3
    I'd better go back to school!

  8. #8

    Default Re: changing base

    Quote Originally Posted by Andrew Poulsom
    Quote Originally Posted by lordrom
    works up to 8, but 9 should be 100 in base 3. your formula returns 30, which is illegal in base 3
    I'd better go back to school!
    Andrew,

    What would be the Excel functions to convert?

  9. #9
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    73,092

    Default Re: changing base

    That's the problem. It involves iteration so I don't think it can be done with standard Excel funtions. Here is a UDF I found:

    Code:
    Function baseconv(InputNum, BaseNum)
       Dim quotient, remainder As Single
       Dim answer As String
    
       quotient = InputNum   ' Set quotient to number to convert.
       remainder = InputNum  ' Set remainder to number to convert.
       answer = ""
    
       Do While quotient <> 0   ' Loop while quotient is not zero.
    
          ' Store the remainder of the quotient divided by base number in a
          ' variable called remainder.
    
          remainder = quotient Mod BaseNum
    
          ' Reset quotient variable to the integer value of the quotient
          ' divided by base number.
    
          quotient = Int(quotient / BaseNum)
    
          ' Reset answer to contain remainder and the previous answer.
          answer = remainder & answer
          ' Convert answer variable to a number.
       Loop
          baseconv = Val(answer)
    End Function

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com