A DESCRIPTION OF THE REQUEST :
I post this as a follow up to a discussion that took place on core-libs-dev, titled "Interest in support for saturated casts?"
It would be great if when fixing "4504839 "Java libraries should provide support for unsigned integer arithmetic", saturated casts could also be provided.
Modern processors seem to have support for this kind of operation, in
x86 there's packssdw in MMX/SSE2.
If the processor doesn't support saturated casts, its just a few lines simple code.
For now this behaviour has to emulated with, which is quite inefficient:
return (short) (x > Short.MAX_VALUE ? Short.MAX_VALUE : (x <
Short.MIN_VALUE ? Short.MIN_VALUE : x));