Thread: decimal to base 8 algorithm

  1. #1
    Registered User
    Join Date
    Apr 2009

    decimal to base 8 algorithm

    I am trying to create a function inside my program that calculates a number in base 8(eg. 11 in base 8 is 13), but I dont know how this conversion works. I just need the method conversion, the code I will write myself. Please explain. Thanks in advance.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    You mean you want to output a number in base 8? You can do that with a loop that takes modulo of the base, displays the digit and divides teh remaining number by base, until there is nothing left of the number. Unfortunately, that gives you the number backwards, so you have to store the digits away and then write them out "last one first".

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Decimal out algorithm
    By rocketman50 in forum Tech Board
    Replies: 1
    Last Post: 02-28-2009, 06:42 PM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  3. I need help with decimal to binary Algorithm
    By webznz in forum C Programming
    Replies: 4
    Last Post: 03-13-2008, 03:52 AM
  4. Binary to Base 10 decimal conversion
    By JFonseka in forum C Programming
    Replies: 13
    Last Post: 11-20-2007, 04:14 PM
  5. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM