ilog2() for very large numbers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Vinokur

    ilog2() for very large numbers

    Dann Corbit has implemented function
    int ilog2 (unsigned long)
    at http://groups.google.com/groups?selm....1498%40client

    Is exist a similar C++-function for very large numbers, e.g., function with signature
    vector<unsigned long> ilog2 (const vector<unsigned long>&)?

    --
    Alex Vinokur
    email: alex DOT vinokur AT gmail DOT com









  • Karl Heinz Buchegger

    #2
    Re: ilog2() for very large numbers

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

    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
    kbuchegg@gascad .at

    Comment

    • Alex Vinokur

      #3
      Re: ilog2() for very large numbers


      "Karl Heinz Buchegger" <kbuchegg@gasca d.at> wrote in message news:41A2F847.8 BDE161D@gascad. at...[color=blue]
      > Alex Vinokur wrote:[color=green]
      > >
      > > Dann Corbit has implemented function
      > > int ilog2 (unsigned long)
      > > at http://groups.google.com/groups?selm....1498%40client
      > >
      > > Is exist a similar C++-function for very large numbers, e.g., function with signature
      > > vector<unsigned long> ilog2 (const vector<unsigned long>&)?
      > >[/color]
      >
      > No.
      > Mostly because vector<unsigned long> is *not* a very large number
      > but an array of numbers, nothing more.[/color]

      I am using vector<unsigned long> to build class BigInt
      at http://groups.google.com/groups?selm....uni-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





      Comment

      • Karl Heinz Buchegger

        #4
        Re: ilog2() for very large numbers

        Alex Vinokur wrote:[color=blue]
        >
        > "Karl Heinz Buchegger" <kbuchegg@gasca d.at> wrote in message news:41A2F847.8 BDE161D@gascad. at...[color=green]
        > > Alex Vinokur wrote:[color=darkred]
        > > >
        > > > Dann Corbit has implemented function
        > > > int ilog2 (unsigned long)
        > > > at http://groups.google.com/groups?selm....1498%40client
        > > >
        > > > Is exist a similar C++-function for very large numbers, e.g., function with signature
        > > > vector<unsigned long> ilog2 (const vector<unsigned long>&)?
        > > >[/color]
        > >
        > > No.
        > > Mostly because vector<unsigned long> is *not* a very large number
        > > but an array of numbers, nothing more.[/color]
        >
        > I am using vector<unsigned long> to build class BigInt
        > at http://groups.google.com/groups?selm....uni-berlin.de
        >
        > operator+() has been defined for BigInt.
        >
        > Now I would like to define operator/() as well.
        > operator/() seems to require using ilog2().[/color]

        ???
        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
        kbuchegg@gascad .at

        Comment

        Working...