ChatGPT aka WokeGPT can't explain the quake inv sqrt hack w/o content warning

Prompt:

explain the following code

###

float q_rsqrt(float number) { long i; float x2, y; const float threehalfs = 1.5F;

  x2 = number * 0.5F;
  y  = number;
  i  = * ( long * ) &y;                       // evil floating point bit level hacking
  i  = 0x5f3759df - ( i >> 1 );               // what the fuck?
  y  = * ( float * ) &i;
  y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
  // y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed

return y;

}

Ans:

This content may violate our content policy or terms of use. If you believe this to be in error, please submit your feedback — your input will aid our research in this area.

Looks like the one usage of the word fuck is enough to trigger the alarms now.


Comments URL: https://news.ycombinator.com/item?id=37802672

Points: 1

# Comments: 0

Read more here: External Link