[ create a new paste ] login | about

Link: http://codepad.org/1ruCSsEW    [ raw code | output | fork ]

AaronMiller - C, pasted on Mar 12:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* rcp-sqrt magic value: 0x5F3759DF */
#include <stdio.h>

void DispIntFloat(unsigned int i) {
  printf("0x%.8X = %f\n", i, *(float *)&i);
}
void DispFloatInt(float f) {
  printf("%f = 0x%.8X\n", f, *(unsigned int *)&f);
}

int main() {
  DispIntFloat(0x5F3759DF);
  DispFloatInt(13211836172961054720.000000f);
  return 0;
}


Output:
1
2
0x5F3759DF = 13211836172961054720.000000
13211836172961054720.000000 = 0x5F3759DF


Create a new paste based on this one


Comments: