473,698 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5268
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******@gasca d.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******@gasca d.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
2422
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 able to lock records within the very large dictionary when records are written to. Estimated number of records will be in the ballpark of 50,000 to 100,000 in his early phase and 10 times that in the future. Each record will run about 100 to 150...
2
6664
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.........." string dec_str = <the same number in decimal represantation> -- Alex Vinokur
10
4989
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 megabits, or a little over 3 megs of memory for just one variable...) I would also need several smaller variables. This came about as I optimised a prime number generator more and more, until I came with the idea to try to find the largest ever, using...
17
12783
by: Sri | last post by:
How do you add an n-bit number in C? Regards, Sri
22
4487
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 and and 5000 out :( I have a suspition is could be down to one of the number functions I am using along the way but im not sure.
3
8205
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; alert(bigpi); I only get the first 17 digits and an exponent. Is there any way to save very large numbers to a variable? I would really like to be able to manipulate pi to a large number of decimal places (say 1,000). Is
2
3167
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 ~10^28 is a bit shy of the at least 10^34 precision I know I'll need at the very least. Actually, I don't need all the precision. I simply need to be able to have numbers that go that high. If the actual precision is only to 15 or 20 or so...
60
1950
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 ending in 5 ..which obviously cannot be prime numbers) can anyone please help me out with the reason?? /*Generate Prime Numbers*/ #include<stdio.h>
2
4206
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 file, (numbers.txt), containing a large (N <= 1000) number of integers. The integers range in value from 0 to 100. The text file has been created with one value on each line. Due to the potential for the sum of the numbers to be very large, you...
0
8680
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.