ilog2() for very large numbers

K

Karl Heinz Buchegger

Alex said:
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++.
 
A

Alex Vinokur

Karl Heinz Buchegger said:
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/[email protected]

operator+() has been defined for BigInt.

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

[snip]
 
K

Karl Heinz Buchegger

Alex said:
I am using vector<unsigned long> to build class BigInt
at http://groups.google.com/[email protected]

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top