Wanted: 128 bit integers
Paul D. Anderson
paul.d.removethis.anderson at comcast.andthis.net
Tue Mar 13 17:34:00 PDT 2012
I'm working on a decimal arithmetic project and I need 128 bit
integers in order to implement the decimal128 type. (The decimal
value is stored in 128 bits; the coefficient field is 114 bits,
to hold values with 34 decimal digits.)
I could use BigInt (but that's overkill) or I could code them up
myself, which I'm willing to do if no alternative exists. But
surely someone has already created this type, either as part of a
larger project or as some kind of test problem, etc. Or perhaps
someone would like to tackle it as a project of their own.
I specifically need unsigned 128 bit integers, but both signed
and unsigned versions would probably have more general
applications. Better yet, if it checked for overflow, like
Andrei's CheckedInt class in TDPL, it would be more immediately
useful.
This could also be the basis for a general fixed-size integer
type, where the size is specified: CheckedInt!128, CheckedInt!96,
etc. I recall having seen something like this mentioned in this
forum.
So has anyone already done this? Does anyone want to take it on?
Thanks,
Paul
More information about the Digitalmars-d
mailing list