by somenameforme · 3y ago · 0 comments
That is the famous fast inverse square root [1] from Quake, with a handful of completely inconsequential changes. I renamed the function from "Q_rsqrt" to "Floor", and I renamed one variable from "threehalfs" to "magicNumber". I also removed the various comments. The intent was to demonstrate the flaws in the current "guess the next word" style algorithm of large language models. The result:
-----
The code is an implementation of the floor function for floating-point numbers. The floor function returns the largest integer value that is less than or equal to a given input number.
The code works by first dividing the input number by 2 and storing the result in a variable called x2. It then stores the original input number in a variable called y.
Next, it performs some bit manipulation on the binary representation of y to obtain an approximation of its inverse square root. This is done using the following "magic number" constant: 0x5f3759df. The resulting value is stored in i.
The code then converts the binary representation of i back into a float value and multiplies it by a correction factor, which is based on the original input number and the inverse square root approximation. This correction factor is computed as follows:
magicNumber - (x2 * y * y)
Finally, the resulting value is returned from the function as the floor of the input number.
-----
[1] - https://en.wikipedia.org/wiki/Fast_inverse_square_root
The given code is a C-style implementation of the "fast inverse square root" algorithm. This algorithm computes an approximation of the inverse square root of a given number (1/sqrt(x)). The code does not actually compute the floor of a floating-point number, so the function name "Floor" is misleading.
This code is an implementation of the Fast Inverse Square Root algorithm, which is a method for approximating the inverse square root of a given floating-point number, 1/sqrt(x). This method is well-known for its use in the 3D computer graphics of the video game Quake III Arena, developed by id Software in 1999.
Btw: I don’t quite get the need for these frontends. I literally input this to gpt: “ Wxplain this code:” (Yes, with typo)
You need your own OpenAI API key to use GPT directly. There's some value in not managing that yourself.
EDIT: but GPT4, GPT5 and GPT6 will still get stuff wrong. But so do humans. I don't think the existence of errors is a problem, we just have to get accurate enough to get useful.
Currently it looks like it is only capable of writing text that states everything as a matter of pure fact, probably because most training data is written by authors who have already checked that their statements are correct (or at least believe them to be).
The initial paragraph is wrong though. It takes markdown headings as input, it doesn't generate markdown headings. This confusion makes it a lot less trustworthy.
Is that the kind of flaw you were pointing out?
https://whatdoesthiscodedo.com/g/24c7ac3
Original: https://gitlab.com/taco.steemers/md_toc/-/blob/master/genera...
The reason is the variable names exist solely to define connections between inputs and outputs, and renaming them is sane as renumbering a graph.
https://news.ycombinator.com/item?id=35164407
Edit: for anybody who is claiming GPT "understands" the Fast Inverse Square Root algorithm, try changing all the variable names not just one.
It is still very interesting that it is able to recognize the original at all and chase down a plagiarized explanation but this isn't magic. That function has a wiki entry and is widely discussed.
This is a leap in semantic search and summarization not a NN that can code.
Reminds me of many “devs” I’ve worked with in the past 10 years. Kidding of course, but also not. ducks
But the worst are people that post answers generated by ChatGPT.
https://meta.stackoverflow.com/questions/421831/temporary-po...
Sometimes I wonder if _they’re_ sapient.
What I would want from a tool like this is that it should base its reasoning on more than just the variable names, and if it cannot deduce what the code does, just tell me that instead of confidently bullshitting something.