This works for both floats and doubles…
Here’s the double version I’m currently using…
__m128d abs_pd(__m128d x)
{
return _mm_andnot_pd(_mm_set1_pd(-0.), x);
}
It’s pretty useful, especially for clamping.
This works for both floats and doubles…
Here’s the double version I’m currently using…
__m128d abs_pd(__m128d x)
{
return _mm_andnot_pd(_mm_set1_pd(-0.), x);
}
It’s pretty useful, especially for clamping.