projects
/
libfirm
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
convert bitfield initializer tarvals before using them
[libfirm]
/
ir
/
be
/
test
/
invsqrt.c
1
/**
2
* magical invsqrt function from Quake III code
3
* see: http://www.codemaestro.com/reviews/9
4
*/
5
6
float InvSqrt(float x)
7
{
8
float xhalf = 0.5f*x;
9
int i = *(int*)&x;
10
i = 0x5f3759df - (i>>1);
11
x = *(float*)&i;
12
x = x*(1.5f-xhalf*x*x);
13
return x;
14
}
15
16
int main(void) {
17
int result = InvSqrt(0.00056);
18
printf("Result: %d (should be 42)", result);
19
return result != 42;
20
}