[Dlang-internal] I need cent and ucent to be implemented soon

Saurabh Das saurabh.das at gmail.com
Thu Apr 29 04:38:52 UTC 2021


On Wednesday, 28 April 2021 at 09:21:54 UTC, user1234 wrote:
> On Tuesday, 27 April 2021 at 18:00:09 UTC, Elmar wrote:
>
>> 128-bit numbers are still extremely large as a count value, 
>> exceeding any common-day numbers, common numbers in 
>> electronics or software. You rarely need 128-bit numbers as 
>> single count values
>
> Yes, if you need ucent/cent you more likely only need the type 
> but only a small subset of the operations allowed on integral 
> types. For example for a wide bitfield, only `&` `|` `^` `<<` 
> `>>` `~` `=`.
>
> The subset required is hypothetically always small enough and 
> people just write their own struct, alias this and a few opover.

We just wrote an Int128 implementation which uses GCC or LDC's 
__int128_t built in data type.

Pros: It's fast
Cons: It does not work at compile time.

If there's interest, I can share it once we complete writing it. 
Currently it's inside an internal library, but it can be 
extracted out.

That said, a D implementation of cent and ucent would be really 
good to have.

Saurabh




More information about the Dlang-internal mailing list