By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,199 Members | 1,458 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,199 IT Pros & Developers. It's quick & easy.

ilog2() for very large numbers

P: n/a
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
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn



Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Alex Vinokur wrote:

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>&)?


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
kb******@gascad.at
Jul 22 '05 #2

P: n/a

"Karl Heinz Buchegger" <kb******@gascad.at> wrote in message news:41***************@gascad.at...
Alex Vinokur wrote:

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>&)?


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....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
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Jul 22 '05 #3

P: n/a
Alex Vinokur wrote:

"Karl Heinz Buchegger" <kb******@gascad.at> wrote in message news:41***************@gascad.at...
Alex Vinokur wrote:

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>&)?


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....uni-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
kb******@gascad.at
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.