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

Home Posts Topics Members FAQ

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 6394
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
12978
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 have managed to generated the Private and Public keys and exchanged public keys and modulus between the clients and server. Please could someone advise me how encrypt a short message, pass the encrypted message across a socket connection and then...
0
1729
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
2076
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
1443
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
6457
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) { case GCD: out = b1.gcd(b2).toString(); break; /** * Returns a BigInteger whose value is the greatest common divisor of * <tt>abs(this)</tt> and <tt>abs(val)</tt>. Returns 0 if * <tt>this==0 &amp;&amp;...
2
2843
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 the API docs , but still need help. Thanks! import java.math.BigInteger; public class Integer { private BigInteger IntegerONE; // both entered as strings from GUI private BigInteger IntegerTWO; public Integer() {
2
2777
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. BigRational is really simple and it just maintains a dividend and denominator and then prints out the decimal form when done with the calculation.
6
13564
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 from char*/string to a numeric representation. Thanks!
11
10506
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 buddy created BigInteger class but it is missing some overloading function like BigInteger.probablePrime(). The code of the BigInteger class developed in the C#.Net can be found here: http://www.codeproject.com/KB/cs/biginteger.aspx
0
8683
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
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
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
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...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2336
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.