3 ms·
It would be interesting to have support for saturated types as well. u8saturated 200 + u8saturated 200 = 255. That's often desired behavior. Saturated arithmet
by vardump 11y ago
It would be interesting to have support for saturated types as well. u8saturated 200 + u8saturated 200 = 255. That's often desired behavior.
Saturated arithmetic is supported in hardware in SSE. Although not much point if the values need to be constantly shuffled between SSE and scalar registers...
- Manishearth 11y ago.saturating_add() exists. You can create a wrapper type around this and implement the Add/Sub/Mul traits.
- vardump 11y agoDoes it have branchless codegen?
- Manishearth 11y agoNot right now (I'm surprised that's the case, there should be intrinsics for it), but that could change.
- dbaupp 11y agoIt gets optimised to be branchless if LLVM thinks that will be faster, yes.