DEV Community

Discussion on: Commenting: where?

Collapse
 
tandrieu profile image
Thibaut Andrieu

I wouldn't be so categorical. The auto-documented code may be possible with high level language like Python or Ruby, and simple business logic. But when dealing with low level kernel code in C, C++ or scientific algorithm, even in Python, I dare you to understand it without comment.
Could-you explain me what does this code ? 😁

// Compute an approximation of 1/sqrt(number)
float Q_rsqrt( float number )
{
    long i;
    float x2, y;
    const float threehalfs = 1.5F;

    x2 = number * 0.5F;
    y  = number;
    i  = * ( long * ) &y;
    i  = 0x5f3759df - ( i >> 1 );
    y  = * ( float * ) &i;
    y  = y * ( threehalfs - ( x2 * y * y ) );
}
Enter fullscreen mode Exit fullscreen mode

For the answer: en.wikipedia.org/wiki/Fast_inverse...

Collapse
 
vulcanwm profile image
Medea

Oh okay