Saturating integer arithmetic
Ola Fosheim Grøstad via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jun 26 07:28:59 PDT 2016
On Sunday, 26 June 2016 at 13:59:03 UTC, Andrei Alexandrescu
wrote:
> On 6/26/16 9:47 AM, Manu via Digitalmars-d wrote:
>> Hi people. I've been working on this colour library when I
>> have free
>> time (almost never!), and I want to work on blending/filtering
>> functions, but that work is kinda blocked by saturating
>> arithmetic
>> logic.
>> I started working on a saturating integer library a few times,
>> but
>> it's much a much bigger job than it appears, and I haven't had
>> enough
>> time for it. (Efficient) implementation tends to be
>> significantly
>> different for every int width and signed/unsigned. I see no
>> use for an
>> inefficient implementation used by a colour library; images
>> tend to be
>> millions of pixels, and inefficiency very quickly adds up.
>
> See the recent thread "DbI checked integral". Saturation is a
> direct goal, and you should be able to optimize operations for
> each type by defining relatively small hooks.
No, saturated operations are typically SIMD instructions.
More information about the Digitalmars-d
mailing list