Lint is a signed large integer data type class library that supports all mathematical operators available to other intrinsic integer data types. The precision is not arbitrary as in other available libraries. Rather, the number of bits that make up a
lint variable is dependent on the value of a
#define directive declared in the header file.
So why yet another large integer library? Several reasons, among which:
- I wanted a class that supported all possible overloaded operators so that I could use a
lint just exactly like I might use an intrinsic data type such as an
long. None of the free implementations I could find seemed to support all over-loadable operators.
- I wanted a class that was specifically created with Visual C++ and IA-32 based PC architecture in mind. I didn't want a library that sacrificed execution speed for the sake of cross-compiler and cross-platform compatibility. I wanted a library that I could optimize with in-line assembly code.
- I wanted a class whose methods were as fast and efficient as possible. Arbitrary-precision logic and floating point logic bring with them a performance hit. This library is efficient because precision is not arbitrary and all operations are strictly integer based. In this way, I could write highly optimized assembly routines given a known data type and size.
Using the code
Once you include the header file in your source, using a
lint is similar to using any other numeric data type in C++. The few notable exceptions are in declaration, assignment, and output.
#include <span class="code-string">"lint.h"
Points of Interest
Implementing the conditional testing was a real bugger. My implementation works, but I think there must be a better way to do it. There are additional things I'd like to do to the library as well.
- Possibly implement faster multiplication and division algorithms using FFT, Barrett, or whatever.
- Add capability to assign a value using a string in any radix from 2 to 36, not just base 10.
- Make use of MMX and XMM registers for even faster inline assembly.
|Initial release||December 4, 2005||by Jeremy A. Wilson|| |
|Update||December 6, 2005||by Jeremy A. Wilson||Discovered my comparison operators were using the wrong assembly instruction which failed to report correctly if the MSB was set in one |
DWORD and not the other.
|Update||December 9, 2005||by Jeremy A. Wilson||After further review of my December 6th fix, I realized I still hadn't fixed it right. Now I have. I also ran a complete set of comparisons.|