Thread: Quarternary numbers.

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    60

    Quarternary numbers.

    Hey,
    im trying to print an integer to stdout in octal, hexadecimal, and quarternary number form.
    I know that for octal:
    Code:
    printf("%03o ", c);
    and for hexidecimal
    Code:
    printf("%02X ", c);
    but what about quarternary?

    thanks

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Use something other than printf(). Not too difficult. If you need help with the source just say so. Otherwise, just break out a notepad and work on it.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    60
    Quote Originally Posted by master5001 View Post
    Use something other than printf(). Not too difficult. If you need help with the source just say so. Otherwise, just break out a notepad and work on it.
    What do you mean ?
    I m trying to convert 100s of numbers from decimal to quarternary.
    Does printf have the functionality to print quarternary form?

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Nope. And its possible, just not with printf(). You will have to write your own function. I have something important to do right now so hang tight and I can walk you through some source.

  5. #5
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    use a recursive function to repeatedly divide the number by 4 until the quotient becomes zero while printing out the remainder.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about random numbers
    By Kempelen in forum C Programming
    Replies: 2
    Last Post: 07-02-2008, 06:28 AM
  2. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  3. Adding Line numbers in Word
    By Mister C in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 06-24-2004, 08:45 PM
  4. the definition of a mathematical "average" or "mean"
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 12-03-2002, 11:15 AM
  5. A (complex) question on numbers
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 02-03-2002, 06:38 PM