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

user1234 user1234 at 12.de
Mon May 3 09:16:41 UTC 2021


On Thursday, 29 April 2021 at 04:38:52 UTC, Saurabh Das wrote:
> On Wednesday, 28 April 2021 at 09:21:54 UTC, user1234 wrote:
>> On Tuesday, 27 April 2021 at 18:00:09 UTC, Elmar wrote:
>>
>>> [...]
>>
>> 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.

Good point. The 128 bits int type I use actually requires to have 
static immutable... `static shared this()` could be used however 
to set the pseudo enums of this type.

> 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.

yeah just publish the DUB package.

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


More information about the Dlang-internal mailing list