Home arrow C++ arrow Page 5 - Large Numbers
C++

Large Numbers


People in general seem to dislike the concept of number arithmetic, especially if it’s all about large numbers – and here we literally mean huge ones. However, the twenty-first century is the era of computers. Our everyday lives are covered by tons of data encapsulated in computers. In this series we’re going to discuss and code operations of which Euler wouldn’t dare to dream.

Author Info:
By: Gabor Bernat
Rating: 5 stars5 stars5 stars5 stars5 stars / 8
July 15, 2008
TABLE OF CONTENTS:
  1. · Large Numbers
  2. · The User Interface
  3. · File Input Lesson
  4. · Addition and Subtraction
  5. · Conclusion

print this article
SEARCH DEVARTICLES

Large Numbers - Conclusion
(Page 5 of 5 )

Now we are ready to start cranking. We have successfully completed some of the basic, though non-trivial tasks. These include representing the number in memory and also finishing the addition and subtraction. Now we can start up the program and test it. In the application linked just a few lines below I included a test method so feel free to play with the numbers. On my halfway decent system the results were the following. Here are the addition results for two 10MB (10* 1024 * 1024 digit numbers) files.

And for two 1MB (1024 * 1024 digit number) files the result are here.

We can remark on the speed of the procedure due to the chunk reading method. Of course better scores can be achieved with a good dual core CPU and proper memory and HDD read/write access times. For the two 10MB addition I managed to get a 450ms time on a dual core CPU. That's a significant difference. And don't forget, here's the source code for a more detailed view. Don't hesitate to download it, and may the muse of knowledge inspire you.

This is all for today. Make sure you come back for the second part, in which I shall discuss a more interesting problem, namely multiplication. It's going to be published here so don't go far. Until then I wish you a fantastic day.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
C++ ARTICLES

- Intel Threading Building Blocks
- Threading Building Blocks with C++
- Video Memory Programming in Text Mode
- More Tricks to Gain Speed in Programming Con...
- Easy and Efficient Programming for Contests
- Preparing For Programming Contests
- Programming Contests: Why Bother?
- Polymorphism in C++
- Overview of Virtual Functions
- Inheritance in C++
- Extending the Basic Streams in C++
- Using Stringstreams in C++
- Custom Stream Manipulation in C++
- General Stream Manipulation in C++
- Serialize Your Class into Streams in C++

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials