I’ve been rather lackadaisical about fixing my “big number” classes, but I’ve finally gotten up off the couch, and I have new versions available.
I’ve changed the names of the bigint and bigdec classes to integer and decimal, respectively, because I thought the “big…” names smelled of Java. I also wrote a small Web page that ties the three classes together.
In a comment to a previous post, Andrew Dalke suggested some additional values I could test; and, sure enough, I found a bug (thanks). (The bug was actually in what’s now called the integer class: I hadn’t guarded against aliasing of the operands to expressions like
I think I remember someone suggesting that some users might prefer classes with “more features”. What additional features did you have in mind? Don’t suggest trig. functions and the like: I’ve limited the <cmath>-like functions that take decimal and rational arguments to those that return exact values. (You might be able to talk me into square root, but that would be successive approximation using Newton’s method which is what I know how to write. I already have a version of the rational class that has quiet NaNs and infinities and a spaceship operator, but I’m not sure I like it.)
As I’ve said before, these classes are not intended for serious numerical work; and numerics experts probably already know where to find better implementations, or could write such themselves.
Update, 2024-02-05: I woke up this morning having in my mind a way to make rational comparisons a bit quicker, so I made that change. I also noticed that I had failed to remove an
By the way, if anybody out there has access to a C++ implementation where FLT_RADIX != 2, I’d appreciate a test of the