你遇到过的源代码中最好的注释是什么?
当前回答
大约1997年,Netscape网络浏览器的UNIX风格的源代码:
/* HP-UX sucks wet farts from dead pigeons' asses */
不幸的是,在Moz开源之前,这些珍珠被移除了……
其他回答
// I dedicate all this code, all my work, to my wife, Darlene, who will
// have to support me and our three children and the dog once it gets
// released into the public.
# dont question, i just felt like throwing some globals in
# this is actually quite pointless as youll soon see
稍后在代码中
#draw the circles (complicated)...dont question
更晚…
# complicated process of drawing the circles in a
# somewhat symmetrical, 3-d pattern
# dont question again
甚至以后……
# will determine if user clicks on die
# i determined these values...dont worry about them
来自我们的一个项目。 在一个源文件末尾的某个地方。
/*@ /\ /\ * @ / \/ \ ----- | | ---- |---\ | | /--\ --- | | ---- /--\ /--\ * @ / -- | | | | | / | | | | |\ | | | | * \---\ / \ | |---| ---- |--/ | | \ | | \ | ---- \ \ * | \------------------------/ /-\ \ | | | | | \ | | -\ | | \| | -\ -\ * | \-/ \ | | | ---- |---/ \--/ \--/ --- | \ ---- \--/ \--/ * \ ------O * \ / --- | | ---- /--\ |--\ /--\ /--\ * | | | | / | |\ | | | | | | | | | * | | | |----- ------- | | \ | ---- | | | | | | | /-\ * | |\ /| | \ WWWWWW/ | | \| | | | | | | | | | * | | \ / | | \------- --- | \ | \--/ |--/ \--/ \--/ * | | \--------------/ | | * / | / | * \ \ \ \ * \-----/ \-----/ */
从《雷神之锤III》的资料中,我在一些随机的帖子中偶然发现了这一点。该文件的完整源代码可以在这里找到。这是一种非常快速的求平方根倒数的方法。至于最好的评论呢?当然,这是一种常见的方法,但考虑到它附着在直线上,它的神奇之处在于它的伟大之处。
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
#ifndef Q3_VM
#ifdef __linux__
assert( !isnan(y) ); // bk010122 - FPE?
#endif
#endif
return y;
}
catch (Domain.ConcurrencyException)
{
// somebody changed it between the time we loaded it and now.
// weird, huh?
}
推荐文章
- 在构建中编写注释的语法是什么?gradle文件?
- Java注释中的/**和/*
- 有没有办法注释掉.ASPX页面中的标记?
- Jenkins:注释可以添加到Jenkins文件中吗?
- TypeScript注释的语法记录在哪里?
- CSV文件可以有注释吗?
- 什么是自文档化代码?它能取代文档化良好的代码吗?
- 在erb中添加注释的最佳方法
- 为什么Python没有多行注释?
- 我应该在批处理文件中使用哪种注释风格?
- 如何在Office VBA编辑器中注释和取消注释代码块
- “# noqa”在Python注释中是什么意思?
- 我可以向pip需求文件添加注释吗?
- 你遇到过的源代码中最好的注释是什么?
- 在Bash中创建多行注释的方法?