473,387 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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



Jul 22 '05 #1
3 5249
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

"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Eric S. Johansson | last post by:
I have an application where I need a very simple database, effectively a very large dictionary. The very large dictionary must be accessed from multiple processes simultaneously. I need to be...
2
by: Alex Vinokur | last post by:
I am looking for an algorithm/method which enables to convert very large hexadecimal numbers to decimal numbers. Here is what I would like to do. string hex_str = "123456789abcdef0.........."...
10
by: Tuvas | last post by:
I've been thinking about writing a program to generate the world's largest prime numbers, just for the fun of it. This would require being able to hold an 8000000 digit number into memory (25...
17
by: Sri | last post by:
How do you add an n-bit number in C? Regards, Sri
22
by: Frinton | last post by:
Hi, I am trying to do some calculations on large numbers (ie 7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it doesn't get it quite right. Its always somewhere between 10...
3
by: CFonville | last post by:
I was wondering if there is any way to store large numbers in a variable? With this simple script: var bigpi = 1234567890123456789012345678901234567890123456789012345678901234567890;...
2
by: Pete Davis | last post by:
I'm interested in writing some chem/biochem related tools for myself, but it appears the Decimal format isn't going to quite cut it for some of the numbers I'm going to be working with. It's max of...
60
by: rhle.freak | last post by:
Here is my code to generate prime numbers.It works absolutely fine when the range is *not very large*. However on initializing i with a large integer it produces erroneous results (some numbers...
2
by: shihaoran | last post by:
I really need help with one my program; it is about arraylist; I do not get it. Can someone please help me with it? Here's the instruction: 1. Your instructor will provide you with a text...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.