Thread: parse truly large numbers to binary

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    2

    parse truly large numbers to binary

    Hi, there

    I am trying to convert 0 to some large int numbers (say, pow(a,c)) to a-binary, where pow(a,c), a and c could be large, say a=3,c=100, so the pow result could easily exceed unsigned long length (2^64-1).

    What I am looking for is: say a=3 c=3, so I 'd deal with 0-26 and convert them into 3-binary (sorry if i call it wrong). Let's pick 11 (in DEC) , I want to convert it to 102 (1*3^2+0*3*1+2*3^0) and store in an int array, s.t.
    bit[0] = 2
    bit[1] = 0
    bit[2] = 1

    I know for if pow(a,c) < 2^64-1 I can use && and pick each bit value, but can anyone help if pow(a,c) > 2^64-1 ? I don't even know how to deal with it since pow(a,c) can not exceed 2^64-1 at all... Actually I do not care about what the large number is, all I want is the each bit's value (0 to c-1) in that range.

    Thanks in advance!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    2

    thanks !

    could you please explain more? I went through the intro and it seems like some free optimized code, so all I do is install it and find the proper func and run it? Is that simple?

    appreciate!
    Quote Originally Posted by Salem

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    It's a library to do maths with very large numbers.
    I can't really say much more because I can't really see what you're trying to achieve.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 07-04-2008, 12:39 PM
  2. Listing binary tree numbers by level
    By Nazgulled in forum C Programming
    Replies: 5
    Last Post: 06-16-2008, 10:36 AM
  3. checking if binary numbers are palindromic
    By Beatz in forum C Programming
    Replies: 3
    Last Post: 01-24-2008, 01:49 PM
  4. Binary division of large numbers
    By hooper in forum C Programming
    Replies: 5
    Last Post: 06-01-2007, 02:33 AM
  5. Binary Numbers and Base 2 Calculation for Longs
    By SlyMaelstrom in forum Tech Board
    Replies: 8
    Last Post: 11-09-2005, 08:30 PM