473,387 Members | 1,621 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.

BigInteger in c++

I have to create a c++ class similar to BigInteger from java...
but i have no idea, how can i implement big numbers at all(mabye store
every digit in list element? :))
how is it properly done?

thanks for help
Jul 22 '05 #1
4 6368
adrin wrote:
I have to create a c++ class similar to BigInteger from java...
but i have no idea, how can i implement big numbers at all(mabye store
every digit in list element? :))

Perhaps you could use a vector of ints, longs or even bitsets.

how is it properly done?


Who knows?


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #2
adrin wrote:
I have to create a c++ class similar to BigInteger from java...
but i have no idea, how can i implement big numbers at all(mabye store
every digit in list element? :))
how is it properly done?


Google for:

arbitrary precision c++ library

I have no first hand experience to talk about, however,

http://swox.com/gmp/

seems to be the best I can see.
Jul 22 '05 #3
"I have to create a c++ class similar to BigInteger from java...
but i have no idea, how can i implement big numbers at all(mabye store
every digit in list element? :))"

If by "each digit" you mean each bit representation I think that would
work. You just need to make sure you
can access individual bits so that the bit operations like shifting
etc. can be implemented without too much
problem. If by digit you mean 13 is represented by two nodes ( 1 and 3)
depending on how you store them
the bit manipulations could get confusing. I might create a register
class that can be
initialized to hold any arbitrary number of bits required by the user.
I would include operations such as
shift left, shift right, circular shift, and , or, etc. You could then
build your integer class using this register
class as a base.

"how is it properly done?"

I don't think there is a "proper" way. There are many good solutions to
most problems. Just think first about
the types of operations you will need to perform on this new type and
determine what information will
be needed to complete these operations.

Jul 22 '05 #4
> I have to create a c++ class similar to BigInteger from java...
but i have no idea, how can i implement big numbers at all(mabye store
every digit in list element? :))
how is it properly done?


Are any informations from the discussion "Proposal: New types in C++0x"
useful for you?
http://groups.google.de/groups?threa...d7e99%40postin
g.google.com

Regards,
Markus
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jerry | last post by:
Hi, I am writing a Java Chatroom application that will implement encryption of messages using the RSA algorithm using the BigInteger class. It uses socket connections to exchange messages. I...
0
by: Krzysztof Adamski | last post by:
Hi, Is it possible in jython to map an PyLong object to other class than BigInteger (i.e. java.lang.Long) ? Thanks for you help, Krzysztof Adamski
8
by: Nafai | last post by:
Hello I would like you guys to give me the best solution for this problem: class bigInteger { private: vector<char> digits; public: ... bigInteger& operator+=(const bigInteger& x)
0
by: hitler123 | last post by:
can anyone say me how to define BigInteger as a datatype in an xsd. this xsd i am uising in the xmlbeans.
19
by: shana07 | last post by:
I don't understand about this program is doing. Could someone please tell me what it is about. Because I have gcd function in one program that calls this function. Thanks a lot switch (opcode) {...
2
by: gemacjr1201 | last post by:
I am creating a GUI for class and need help with my program. My program takes 2 big integers and adds them together. First how do I declare my 2 Big Integers and then add them together? I have read...
2
by: jehugaleahsa | last post by:
Hello: I am currently working on a some simple (not really) classes called BigInteger and BigRational. They are pretty much identical to Java's BigInteger and BigDecimal classes, respectfully. ...
6
by: mearvk | last post by:
Does C++ or C have something roughly equivalent to this: http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html What I need is a way to quickly convert between decimal and binary and...
11
by: imranisb | last post by:
Hi, Im developing RSA cryptography based application in VC#.Net 2.0 and need to use "BigInteger.probablePrime()". I know that VC#.Net 2.0 doesn't have the BigInteger class but found that one...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.