3 ms·
Or use saturating arithmetic, loads of common processors have instructions for that.
by jensnockert 15y ago
Or use saturating arithmetic, loads of common processors have instructions for that.
- carbonica 15y agox86 only has SIMD instructions for it, IIRC.
- onan_barbarian 15y agoYou do recall correctly. Further, x86 only provides these SIMD operations on 8-bit and 16-bit quantities, not on 32-bit or 64-bit quantities (although all these types can be packed into a SIMD register and operated on with at least some operations; for example regular, non-saturating add). SSE has a menagerie of non-orthogonal oddities, unfortunately; this is only one of them.
- adobriyan 15y agoAnd IIRC it's int16_t/uint16_t max.
- tedunangst 15y agoYes, "don't use C" can solve lots of problems, but it doesn't solve them when using C.