I wrote my own Decimal class, which uses an int64_t
mantissa. I believe this means it can represent 18 digits (would be 19 if unsigned).
I need to represent two ranges of number:
- Type A as large as 99,999,999
- Type B as small as 1e-9.
Until now, this was fine as these numbers were only added/subtracted. However, I now need to multiply and divide by each other.
I'm concerned I'm close to running out of digits.
- Should I use 128 bits instead?
- Are there any easy/simple 128 bit C++ decimal libraries?
- Could I simply replace my
int64_t
with__m128i
?
I am not writing public/library code and my architecture will always be Linux x86. I'm currently using GCC but could switch to Clang.