Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

CInt96 v1.04 - 96 Bit Integers

0.00/5 (No votes)
3 Mar 2000 1  
A Freeware MFC class which provides 96 bit integers.
  • Download source files - 10 Kb
  • Introduction

    If you have every been doing any arithmetic which stretches the limits of the build in __int64 data type in Visual C++, then here is a class which gives you an extra 4 bytes to play with.


    Features
    Usage
    History
    Enhancements
    Contacting the Author


    Features

    • Provides constructors which convert between all the basic types (including __int64) to CInt96.
    • All the standard operators are provided allowing the class to be used as if it was an intrinsic data type.
    • Methods are provided to convert to and from Hex, binary and decimal strings.
    • Functions are available to allow individual bits to be easily set or retrieved.

    The source zip file contains the CInt96 source code and a simple console program which exercises the class.


    Usage

    • To use the class in your code simply include int96.cpp in your project and #include int96.h in which ever of your modules needs to make calls to the classes.
    • Your code will need to include MFC either statically or dynamically.
    • To see the class in action, have a look at the code in main() in the module test.cpp.


    History

    v1.0 (11 July 1999)
    • Initial public release.

    V1.01 (17 October 1999)

    • Fix for the function FormatAsDecimal() which was failing when the number starts with a "10".

    V1.02 (26 October 1999)

    • Fixed bug in operator!=.
    • Fixed bug in operator^.
    • Fixed bug in operator|.
    • Fixed bug in operator&.
    • All relational and equality operators now return int instead of BOOL.
    • Provision of operators which convert back to basic C types.
    • Improved the performance of operator*.
    • Fixed problem with 0/0 which was returning 0 instead of the correct value of undefined, i.e. divide by 0 exception. Thanks to G.J.E. Visser for finding all these bugs <g>.

    V1.03 (28 October 1999)

    • Fixed another bug in operator!=.
    • Removed the use of MAXDWORD and replaced with 0xFFFFFFFF.

    V1.04 (5 December 1999)

    • Fixed problem with operator* which was giving incorrect results in some cases. Thanks go to G.J.E. Visser for finding this.


    Planned Enhancements

    • Optimize the code through the use of inlining and improved algorithms.
    • Generalize the class to make it arbitrary precision.
    • Improve the sample app as at the moment it just tests out most of the methods provided by CInt96.
    • If you have any other suggested additions, comments or bug fixes, please let me know so that I can try my best to incorporate them into the next version of CInt96.


    Contacting the Author

    PJ Naughter
    Email: pjn@indigo..ie
    Web: http://www.naughter.com
    5 December 1999

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here