My Big Number library
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 7 of 7

Thread: My Big Number library

Threaded View

  1. #1
    Join Date
    Aug 2009
    Finally back in Alaska

    My Big Number library

    Hello all,

    Ive been away for a few months now but finally moved back to Alaska yay. I am picking up my pet project again and would like to put it out there for anyone who wishes to take a look to do so and give some advice on How to improve it. The library is fairly compex (to me at least) so Ill make a few posts as to whats in it and how to use it. The library is only available in 64 bit mode, I keep meaning to implement a 32 bit mode of it but.....

    The best way to get an idea of the internals is if you have Doxygen, all files are commented to create full documentation with Doxygen, even the .asm files are commnented though to use it you need the asmtodoxy script (dont remember where I found it but will try to find it again and post the link as well as my versions of the .bat to convert the asm files for Doxygen and the Doxy file to create the documents).

    There are just a few things to note, the assembly language routines uses a memory management routine that I wrote and you have to be aware of this if you are going to change the source in the libraries, there are routines in the managed and native libraries to get and free memory. You can change the running behavior by going into the innards file and change the _usemalloc global variable to 1, this will force all memory requests to use malloc and free (you should be able to change this variable in the middle of running so that the arrays that were filled using my routine before the change can work with the arrays filled using malloc without any problems, you should be able to replace the arrays that were filled using my routine with one that you create using malloc and my free routine should recognize it and free it correctly.

    The complex versions of the classes are not operational yet.

    All of the managed classes have implicit conversions from the built in types (as well as string types) and explicit conversions to those types though not all of the explicit conversions are debugged yet. This means you can use members of my library with all the built in types without worrying about conversions as long as you expect on of my classes as a return value.

    The managed classes are by far more fully implemented, the native versions of the classes are mainly used as containers so that the managed classes can access the assembly language routines directly.

    BI is the managed version of BigInteger, BD is the managed version of BigDecimal, and BF is the managed version of BigFraction. All native classes are preceded with a C and all assembly language versions are preceded by an A (though the native and assembly language versions are the same and used interchangeably).

    All numbers are kept in an array as an unisgned number using Big Endian, the sign is kept in a variable names _sign (0=positive 1=Negative), the decimal versions also have a _decimalpoint variable to keep track of the position of the decimal point in the number, the decimal number is kept in an array as if there was no decimal point, the arrays are changed internally to make the decimal points line up for the algs that need it.

    Ill answer any other questions if you just post them, I had to strip everything out in order to get it to fit, so none of my addon libraries are included as well as what I had for the 32 bit stuff.

    Anyways, thanks for any insight as to how to improve it.
    Attached Files Attached Files
    • File Type: zip (214.8 KB, 1299 views)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)