ilog2() for very large numbers

Discussion in 'C++' started by Alex Vinokur, Nov 23, 2004.

  1. Alex Vinokur

    Alex Vinokur Guest

    Alex Vinokur, Nov 23, 2004
    #1
    1. Advertising

  2. Alex Vinokur wrote:
    >
    > Dann Corbit has implemented function
    > int ilog2 (unsigned long)
    > at http://groups.google.com/groups?selm=lkPa4.2165$I41.1498@client
    >
    > Is exist a similar C++-function for very large numbers, e.g., function with signature
    > vector<unsigned long> ilog2 (const vector<unsigned long>&)?
    >


    No.
    Mostly because vector<unsigned long> is *not* a very large number
    but an array of numbers, nothing more.

    There may be libraries out there, which treat vector<unsigned long>,
    or somthing like that embedded in a class, as a sort of very large
    number. But those libraries are outside the scope of C++.

    --
    Karl Heinz Buchegger
    Karl Heinz Buchegger, Nov 23, 2004
    #2
    1. Advertising

  3. Alex Vinokur

    Alex Vinokur Guest

    "Karl Heinz Buchegger" <> wrote in message news:...
    > Alex Vinokur wrote:
    > >
    > > Dann Corbit has implemented function
    > > int ilog2 (unsigned long)
    > > at http://groups.google.com/groups?selm=lkPa4.2165$I41.1498@client
    > >
    > > Is exist a similar C++-function for very large numbers, e.g., function with signature
    > > vector<unsigned long> ilog2 (const vector<unsigned long>&)?
    > >

    >
    > No.
    > Mostly because vector<unsigned long> is *not* a very large number
    > but an array of numbers, nothing more.


    I am using vector<unsigned long> to build class BigInt
    at http://groups.google.com/groups?selm=bndg9j$vbfia$-berlin.de

    operator+() has been defined for BigInt.

    Now I would like to define operator/() as well.
    operator/() seems to require using ilog2().

    [snip]

    --
    Alex Vinokur
    email: alex DOT vinokur AT gmail DOT com
    http://mathforum.org/library/view/10978.html
    http://sourceforge.net/users/alexvn
    Alex Vinokur, Nov 23, 2004
    #3
  4. Alex Vinokur wrote:
    >
    > "Karl Heinz Buchegger" <> wrote in message news:...
    > > Alex Vinokur wrote:
    > > >
    > > > Dann Corbit has implemented function
    > > > int ilog2 (unsigned long)
    > > > at http://groups.google.com/groups?selm=lkPa4.2165$I41.1498@client
    > > >
    > > > Is exist a similar C++-function for very large numbers, e.g., function with signature
    > > > vector<unsigned long> ilog2 (const vector<unsigned long>&)?
    > > >

    > >
    > > No.
    > > Mostly because vector<unsigned long> is *not* a very large number
    > > but an array of numbers, nothing more.

    >
    > I am using vector<unsigned long> to build class BigInt
    > at http://groups.google.com/groups?selm=bndg9j$vbfia$-berlin.de
    >
    > operator+() has been defined for BigInt.
    >
    > Now I would like to define operator/() as well.
    > operator/() seems to require using ilog2().


    ???
    Not really.

    You could do it with logarithms and power functions.
    But it definitily is not necessary.
    (I don't think that kids at an age of 9 use logarithms
    to do divisions :)

    I don't think it is a shame to download one of the many
    available BigInt libraries, study the source code, analyze
    it, figure out how they do it and then adopt what you have learned
    to your own class.

    --
    Karl Heinz Buchegger
    Karl Heinz Buchegger, Nov 23, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raymond Arthur St. Marie II of III

    very Very VERY dumb Question About The new Set( ) 's

    Raymond Arthur St. Marie II of III, Jul 23, 2003, in forum: Python
    Replies:
    4
    Views:
    470
    Raymond Hettinger
    Jul 27, 2003
  2. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    1,615
    Merrill & Michele
    Oct 19, 2004
  3. Abhishek Jha

    very very very long integer

    Abhishek Jha, Oct 16, 2004, in forum: C Programming
    Replies:
    4
    Views:
    418
    jacob navia
    Oct 17, 2004
  4. Peter

    Very very very basic question

    Peter, Feb 8, 2005, in forum: C Programming
    Replies:
    14
    Views:
    512
    Dave Thompson
    Feb 14, 2005
  5. bmm
    Replies:
    0
    Views:
    136
Loading...

Share This Page