Development Cycles
  Home arrow Development Cycles arrow Page 4 - Division of Large Numbers
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DEVELOPMENT CYCLES

Division of Large Numbers
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-03-10

    Table of Contents:
  • Division of Large Numbers
  • Newton's Iteration
  • The Code Snippet
  • Epilogue and Tests

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Division of Large Numbers - Epilogue and Tests


    (Page 4 of 4 )

    Now the first thing you may observe about the performance of this method is that it's dependent upon how far we will take the calculation of the inverse number. If we have some easier numbers, let's say two, for which the inverse can be calculated instantly, the process will require only a very little time. Needless to say, once we move to three this process gets more complicated and it will require consistently more time.

    Here are the run times first for one divided by two, then by two.



    +1

    +2

    Division:

    +0.5


    And then for three:


    +1

    +3

    Division:

    +0.3333333333333333333333333333333333333333333333............


    The iteration depends mainly how fast we can multiply; as we have to multiply a 5*2^i number at each step (where i stays for the current iteration number). Finally, we must say that the result won't be perfect. An error rate of 5*2^i precision exists, as after that the inverse is not calculated, so we should round the result for a perfect operation. Due to this 2/6 is not 0.5, instead you'll get 0,4999.... You get the picture. Here you have the archived source files of the entire project:



    There we have it, folks, a class that can handle the basic operations with some really large or precise numbers. It may seem at first like a difficult job to do it right, but it turned out to be not too hard to accomplish. Now I invite you to implement other functions and/or operations into it. For example, why not try one that will calculate the factorial of a number if it is of the integer type? Or try calculating the square of a number; it can be resolved in the same fashion as the division using Newton's Iteration.

    I want to thank you for investing time in reading this article and also encourage you to ask any question you might have here on the blog or on our friendly forum over the DevHardware. Have a great 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.

     

    DEVELOPMENT CYCLES ARTICLES

    - Division of Large Numbers
    - Branch and Bound Algorithm Technique
    - Dynamic Programming Algorithm Technique
    - Genetic Algorithm Techniques
    - Greedy Strategy as an Algorithm Technique
    - Divide and Conquer Algorithm Technique
    - The Backtracking Algorithm Technique
    - More Pattern Matching Algorithms: B-M
    - Pattern Matching Algorithms Demystified: KMP
    - Coding Standards
    - A Peek into the Future: Transactional Memory
    - Learning About the Graph Construct using Gam...
    - Learning About the Graph Construct using Gam...
    - Learning About the Graph Construct using Gam...
    - How to Strike a Match







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek