VLONG LIBRARY version 1.1 Those with an interest in number theory and, more recently, cryptography are sometimes frustrated by the lack of a simple way to perform arithmetic on arbitrarily large integers - 200 and 300 digits long for instance. The development of the C++ language allows a user, with a suitable library, to deal with these sorts of numbers as easily as with conventional long's and int's. By including the enclosed header file "vlong.h" in your source code, "vlong10.lib" in your link, and declaring your integers as vlong rather than as int or long, your integers can be 60 to 80 digits long - version 2.0 (available by registering) allows 8000 digit long numbers! THERE ARE NO WARRANTIES AS TO THIS SOFTWARE, WHETHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR FUNCTIONALITY. Limitations: This library requires a 80386SX or later processor - it does not require a floating point coprocessor. The library has been tested under DOS and Windows using the Large memory model. It is for Borland C++ only (developed using version 4.52). Since most of the capabilities of this library are provided by regular arithmetic operators like +,-,*,/,% etc., only a few named functions are required. These are illustrated in the demo program "demo.cpp". They Are: vlong PowerMod(const vlong& x, const vlong& y, const vlong& mod = 0); // PowerMod works out x to the y power mod ... if mod = 0 or not given, // calculation is not modular char* vtoa(const vlong& arg2, char *outstring); // convert to char // turns vlong into a nul terminated character string vlong atov(char *instring); // character to number // turns nul terminated character string into a vlong void Import(char *instring, vlong* numb, int n = 0); // moves n characters of a string into a vlong so they can be dealt // with as a number ... e.g. for RSA encryption. if n is 0 or not // given, goes to the first null character void Export(const vlong& numb, char *outstring, int n = 0); // moves n characters of a vlong into a character string so they can // be output ... e.g. following decryption int CharLength(const vlong& arg); // gives the largest number of characters that is shorter than a given // number .. i.e add 1 to result to get number of characters that will // hold a given number char* vlong_version(); // returns library version # as a character string All operators work as with int's and long's EXCEPT: operators &,|,^,~, and shift not supported in this version - they are in the version available by registering. >> and << function as iostream operators There are a few small differences from the way you use int's and longs: vlong a; ... if (a) {... some code ...} // will not work if (a != 0) {... some code ...} // this is OK if (!a) {... some code ...} // this is however OK ... vlong a = 345876098123; // will not work if the number is // bigger than a long vlong a = "345876098123"; // this is OK vlong b = 345876098; // this is OK as the number is shorter vlong c = "0x567AB345"; // this is OK (hexadecimal) but // octal is not supported in the quotes // note that compile time errors in // the quotes are not detected This library is provided as copyright shareware. Feel free to use it for personal use and distribute it for others to try. If you find it useful, you can obtain a registered copy by registering through the CompuServe Shareware registry [GO SWREG] - the registration ID is 9732. Alternatively, you can send a payment of $20 by cheque or money order to: Larry Roberts 1660 Arbutus Street, Vancouver, BC, CANADA V6J 3X2 (CompuServe 103331,575) The registered 16 bit version [2.0] supports much larger numbers [8000 digits] and allows the use of the logical operators | (or) ^ (xor) & (and) ~ (not) << (left shift) and >> (right shift) as well as the arithmetic and comparison operators. Registration also entitles you to a 32 bit version [3.0] supporting even larger integers. Please contact me for permission if you wish to redistribute the library as part of a product. Also, if you encounter any bugs in the library that have escaped me, please let me know so I can fix them.