Wanted: 128 bit integers

Alex Rønne Petersen xtzgzorex at gmail.com
Tue Mar 13 17:37:18 PDT 2012


On 14-03-2012 01:34, Paul D. Anderson wrote:
> 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
>

The D language specifies 128-bit integers: cent and ucent. They just 
aren't implemented yet...

-- 
- Alex


More information about the Digitalmars-d mailing list