[ create a new paste ] login | about

Link: http://codepad.org/VVKSUN1p    [ raw code | fork ]

AaronMiller - C, pasted on Aug 19:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
float _fsel_branchless(float f, float x, float y) {
	unsigned int msk, res;

	msk = -(((*(unsigned int *)&f)>>31)&1);
	res = ((msk)&*(unsigned int *)&y)|((~msk)&*(unsigned int *)&x);

	return *(float *)&res;
}
float _fsel(float f, float x, float y) {
	return f < 0.0f ? y : x;
}

/*
_fsel_branchess  : 3.566362 second(s)
_fsel            : 4.344463 second(s)
*/


Create a new paste based on this one


Comments: