(Click the public account above to follow quickly)
From: Jobbole Group
Link: http://group.jobbole.com/9907/
This is a discussion thread from Quora, where the original poster said:
If it’s a single line of code, it must be practical, not obfuscated or confusing. For example: while (*n++=*i++) ; (← Those who understand can explain in the comments)
I want to find some more complex programs. Of course, ① I’m not asking you to post those that require many function calls to return results; ② I want to see examples where a single line of code almost completes all the work.
Hayri Uğur Koltuk recommended the code for the fast inverse square root algorithm used in Doom 3:
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 heck?
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;
}
Look at the highlighted line on line 8! 0x5f3759df!
[Updated on 2015-10-29]
Pierre Raii mentioned that one day while passing by the department head’s office at school, he saw a paper posted on the door saying that C language is not that difficult.
void (*(*f[])())()

The image has an English explanation; those who understand can translate or explain it.
Jefferson Steelflex reminded us:
If anyone finds this declaration confusing, check out the right-left rule for pointers.
[Updated on 2015-10-29]
Eric Wadsworth recommended:
I had a former colleague who worked at NASA doing fluid dynamics simulations. He once encountered a bug that took the team three whole weeks to track down. He showed me the C code, which had a line similar to this:
c = ******a;
Stephan Froede said he also encountered something similar:
char ****************a;
He couldn’t remember how many * there were, and there were no comments; he called it code from hell, haha.
Selected comments from Jobbole Group
YuHao
A magical method to quickly convert a double type integer to int, should count: http://stackoverflow.com/q/17035464/1009479, also has a magic number: 6755399441055744.0, seen in Lua source code.
From void (*(*f[])())() you can’t tell what type f is, you can bookmark http://cdecl.org/, you won’t regret it. (The manual parsing rule is from right to left, from inside out, C++ is basically similar, the syntax is more complex than C)
Ace
The line of code in the photo: void (*(*f[])())()
Defines f as an unspecified size array of pointers, where the pointers point to { a function that returns [a pointer to a function with no return value] }
Is that the meaning?
If you find this article helpful, please share it with more people.
Follow “Algorithm Enthusiasts” to improve your programming skills
