﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-山寨科技-随笔分类-转载</title><link>http://www.cppblog.com/Chipset/category/9274.html</link><description /><language>zh-cn</language><lastBuildDate>Fri, 20 Aug 2021 02:32:36 GMT</lastBuildDate><pubDate>Fri, 20 Aug 2021 02:32:36 GMT</pubDate><ttl>60</ttl><item><title>朱丽安娜科普克</title><link>http://www.cppblog.com/Chipset/archive/2021/08/13/217779.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Fri, 13 Aug 2021 13:17:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2021/08/13/217779.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/217779.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2021/08/13/217779.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/217779.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/217779.html</trackback:ping><description><![CDATA[<p class="MsoNormal"><span lang="ZH-CN" style="font-size: 10pt; font-family: " comic="" sans=""  ms";"="" ms";="" font-size:=""  10pt;"="">鉴于小学英语</span><span style="font-size: 10pt; font-family: " comic="" sans=""  ms";"="">Reach G(第6册)</span><span lang="ZH-CN" style="font-size: 10pt; font-family: " comic="" sans=""  ms";"="" ms";="" font-size:=""  10pt;"="">上的一篇文章</span><span style="font-size: 10pt; font-family: " comic="" sans=""  ms";"="">The Girl Who Fell from the Sky</span><span lang="ZH-CN" style="font-size: 10pt; font-family: " comic="" sans=""  ms";"="" ms";="" font-size:=""  10pt;"="">，<a href="http://www.cppblog.com/Chipset/archive/2021/08/11/217695.html">在这里</a>。于是打算了解一下作者(主人公)朱丽安娜科普克</span><span style="font-size: 10pt; font-family: " comic="" sans=""  ms";"="">(</span><span lang="ZH-CN" style="font-size: 10pt; font-family: " comic="" sans=""  ms";"="" ms";="" font-size:=""  10pt;"="">朱丽安娜迪拉</span><span style="font-size: 10pt; font-family: " comic="" sans=""  ms";"="">)</span><span lang="ZH-CN" style="font-size: 10pt; font-family: " comic="" sans=""  ms";"="" ms";="" font-size:=""  10pt;"="">。</span><span style="font-size: 10pt; font-family: " comic="" sans=""  ms";"="" ms";="" font-size:=""  10pt;"="" 13.3333px;"="">人物介绍</span><span style="font-size: 10pt; font-family: " comic="" sans=""  ms";"="" ms";="" font-size:=""  10pt;"="">选自E文维基，以下为译文。</span><span style="font-family: " comic="" sans=""  ms";"="" ms";="" font-size:=""  10pt;"=""><br /></span><span style="font-size: 10pt;" comic="" sans=""  ms";="" font-size:=""  10pt;"="">PS:&nbsp;</span><span style="font-size: 10pt;" comic="" sans=""  ms";="" font-size:=""  13.3333px;"="">翻译能很好的训练一个人的英语和汉语句子组织能力，时不时的让学英语的娃尝试一下翻译英语课文也算是某种锻炼吧。</span></p><p class="MsoNormal"><span lang="ZH-CN" style="font-family: " comic="" sans=""  ms";="" font-size:=""  10pt;"=""></span><span lang="ZH-CN" style="font-family: " comic="" sans=""  ms";="" font-size:=""  10pt;"=""><br /></span><o:p></o:p></p><p class="MsoNormal" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
margin-left:0in;line-height:normal"><span style="font-family: DengXian; font-size: 12pt;">朱丽安娜科普克</span><span style="font-size: 12pt;">(</span><span style="font-family: DengXian; font-size: 12pt;">出生于</span><span style="font-size: 12pt;">1954</span><span style="font-family: DengXian; font-size: 12pt;">年</span><span style="font-size: 12pt;">10</span><span style="font-family: DengXian; font-size: 12pt;">月</span><span style="font-size: 12pt;">10</span><span style="font-family: DengXian; font-size: 12pt;">日</span><span style="font-size: 12pt;">)</span><span style="font-family: DengXian; font-size: 12pt;">，婚后名字朱丽安娜迪拉，是一个德国</span><span style="font-size: 12pt;">-</span><span style="font-family: DengXian; font-size: 12pt;">秘鲁哺乳动物学家。她是</span><span style="font-size: 12pt;">1971</span><span style="font-family: DengXian; font-size: 12pt;">年兰萨</span><span style="font-size: 12pt;">508</span><span style="font-family: DengXian; font-size: 12pt;">航班空难的唯一幸存者，空难发生后独自一人在亚马逊热带雨林生活了</span><span style="font-size: 12pt;">11</span><span style="font-family: DengXian; font-size: 12pt;">天。他从</span><span style="font-size: 12pt;">3000</span><span style="font-family: DengXian; font-size: 12pt;">米</span><span style="font-size: 12pt;">(9843</span><span style="font-family: DengXian; font-size: 12pt;">英尺</span><span style="font-size: 12pt;">)</span><span style="font-family: DengXian; font-size: 12pt;">坠落，落地时仍然被安全带捆在座椅上。<br /><br /></span></p>  <p><strong><span style="font-family: DengXian; font-size: 12pt;">事前</span></strong></p>  <p><span style="font-family: DengXian; font-size: 12pt;">朱丽安娜于</span><span style="font-size: 12pt;">1954</span><span style="font-family: DengXian; font-size: 12pt;">年出生于秘鲁利马，父母都是在利马自然历史博物馆工作的德国人。她是生物学家汉斯威廉科普克和鸟类学家玛丽亚科普克的唯一孩子。在朱丽安娜</span><span style="font-size: 12pt;">14</span><span style="font-family: DengXian; font-size: 12pt;">岁时，其父母带她去亚马逊雨林建造研究基地</span><span style="font-size: 12pt;">--</span><span style="font-family: DengXian; font-size: 12pt;">潘古那。在这里她成了一个&#8220;丛林孩子&#8221;，学了野外生存技能。教育当局不同意这样做，要求朱莉安娜回到利马亚历山大冯洪堡德意志学校参加考试。她于</span><span style="font-size: 12pt;">1971</span><span style="font-family: DengXian; font-size: 12pt;">年</span><span style="font-size: 12pt;">12</span><span style="font-family: DengXian; font-size: 12pt;">月</span><span style="font-size: 12pt;">23</span><span style="font-family: DengXian; font-size: 12pt;">日在此校毕业。<br /><br /></span></p>  <p><strong><span style="font-family: DengXian; font-size: 12pt;">空难</span></strong></p>  <p><span style="font-family: DengXian; font-size: 12pt;">朱丽安娜科普克在经历磨难上有双重生存故事可供讲述。在</span><span style="font-size: 12pt;">1971</span><span style="font-family: DengXian; font-size: 12pt;">年圣诞节前夕，朱丽安娜搭乘了兰萨</span><span style="font-size: 12pt;">508</span><span style="font-family: DengXian; font-size: 12pt;">航班。那时她刚从高中毕业，她的母亲玛丽亚本打算在</span><span style="font-size: 12pt;">1971</span><span style="font-family: DengXian; font-size: 12pt;">年</span><span style="font-size: 12pt;">12</span><span style="font-family: DengXian; font-size: 12pt;">月</span><span style="font-size: 12pt;">19-20</span><span style="font-family: DengXian; font-size: 12pt;">日带着女儿去潘古那，但是朱丽安娜希望能在</span><span style="font-size: 12pt;">12</span><span style="font-family: DengXian; font-size: 12pt;">月</span><span style="font-size: 12pt;">23</span><span style="font-family: DengXian; font-size: 12pt;">日去利马参加毕业典礼。玛丽亚同意，打算圣诞节前夕再飞往潘古那，可是除了里尼思君特欧航空</span><span style="font-size: 12pt;">(</span><span style="font-family: DengXian; font-size: 12pt;">兰萨</span><span style="font-size: 12pt;">)</span><span style="font-family: DengXian; font-size: 12pt;">还有空余其余所有航班的席位均已售罄。尽管丈夫汉斯威廉强烈要求妻子不要乘坐那家航空公司的航班，因为该航空公司早已臭名昭著，但最终她们还是预定了机票。飞机起飞不久遭遇闪电，在空中开始解体并一头冲向地面。朱丽安娜发现自己一直被捆在座椅上，下落将近</span><span style="font-size: 12pt;">2</span><span style="font-family: DengXian; font-size: 12pt;">英里最终落入秘鲁热带雨林。</span></p>  <p><span style="font-family: DengXian; font-size: 12pt;">在朱丽安娜科普克的此次事件上，专家指出由于在下降中她被安放到座椅上才导致她活了下来，只是断了锁骨而已。她是该航班的唯一幸存者，顺着溪流在雨林里生活了</span><span style="font-size: 12pt;">11</span><span style="font-family: DengXian; font-size: 12pt;">天。</span></p>  <p><span style="font-family: DengXian; font-size: 12pt;">在她醒过来后丛林里的昆虫不再叮咬她，可是蛆已经感染了她的胳膊，</span><span style="font-size: 12pt;">9</span><span style="font-family: DengXian; font-size: 12pt;">天后，她找到了一处露营地。在此，她给自己进行了初级治疗，例如用汽油浇到蛆感染的部位。蛆害怕汽油就离开了伤口。几个小时候后，运木工人发现了她，给与基本医疗并把她带到更宜居的区域，然后她被空运到医院。</span></p>  <p><span style="font-family: DengXian; font-size: 12pt;">伤口恢复后，朱丽安娜帮助搜救队定位失事地点和搜救死难者尸体。她妈妈的尸体于</span><span style="font-size: 12pt;">1972</span><span style="font-family: DengXian; font-size: 12pt;">年</span><span style="font-size: 12pt;">1</span><span style="font-family: DengXian; font-size: 12pt;">月</span><span style="font-size: 12pt;">12</span><span style="font-family: DengXian; font-size: 12pt;">日被发现。朱丽安娜回到德国后伤口完全恢复了正常。跟父母类似，朱丽安娜获得生物学学位后返回秘鲁继续深入研究蝙蝠。她的双重生存故事成了书和电影的主体，其中包括了她的自传和他传，&#8220;当我从天而降&#8221;，以及导演沃纳赫尔佐格的纪录片&#8220;翅膀上的希望&#8221;。他</span><span style="font-size: 12pt;">(</span><span style="font-family: DengXian; font-size: 12pt;">沃纳赫尔佐格</span><span style="font-size: 12pt;">)</span><span style="font-family: DengXian; font-size: 12pt;">在</span><span style="font-size: 12pt;">1971</span><span style="font-family: DengXian; font-size: 12pt;">年也预定了她</span><span style="font-size: 12pt;">(</span><span style="font-family: DengXian; font-size: 12pt;">朱丽安娜</span><span style="font-size: 12pt;">)</span><span style="font-family: DengXian; font-size: 12pt;">的那次航班，飞机起飞前最后一分钟改变计划，从而躲过一劫。<br /><br /></span></p>  <p><strong><span style="font-family: DengXian; font-size: 12pt;">事后</span></strong></p>  <p><span style="font-family: DengXian; font-size: 12pt;">朱丽安娜的侥幸存活成了各种瞎猜推断的主题。"很明显她被安全带捆在座椅上有了某种程度的盾牌和缓冲，而且理论上外围整排的座椅，就是朱丽安娜两边的那些，起到了降落伞的作用，减缓了她下落的速度..."。&#8220;风暴漂移以及落地点厚厚的枝叶可以进一步降低里冲击力...&#8221;。</span></p>  <p><span style="font-family: DengXian; font-size: 12pt;">朱丽安娜回到德国彻底康复过来，走了父母一样的路，在基尔大学学习生物，</span><span style="font-size: 12pt;">1980</span><span style="font-family: DengXian; font-size: 12pt;">年毕业。在慕尼黑麦克西米兰大学获得博士学位后返回到秘鲁展开哺乳动物研究，专注于蝙蝠，在</span><span style="font-size: 12pt;">1987</span><span style="font-family: DengXian; font-size: 12pt;">年发表论文，&#8220;秘鲁热带雨林里一个蝙蝠生物王国的研究&#8221;。</span><span style="font-size: 12pt;">1989</span><span style="font-family: DengXian; font-size: 12pt;">年朱莉安娜科普克和一个专注于研究寄生黄蜂的昆虫学家艾力克迪拉结婚。</span><span style="font-size: 12pt;">2000</span><span style="font-family: DengXian; font-size: 12pt;">年朱丽安娜接管了潘古那当上了主任，父亲去世了。</span></p>  <p><span style="font-family: DengXian; font-size: 12pt;">现在朱丽安娜迪拉在慕尼黑巴伐利亚动物学蒐藏研究中心当管理员。她的自传和他传&#8221;当我从天而降&#8221;</span><span style="font-size: 12pt;">(</span><span style="font-family: DengXian; font-size: 12pt;">德语</span><span style="font-size: 12pt;">: Als ich vom Himmel fie)</span><span style="font-family: DengXian; font-size: 12pt;">于</span><span style="font-size: 12pt;">2011</span><span style="font-family: DengXian; font-size: 12pt;">年</span><span style="font-size: 12pt;">3</span><span style="font-family: DengXian; font-size: 12pt;">月</span><span style="font-size: 12pt;">10</span><span style="font-family: DengXian; font-size: 12pt;">日由派珀林格出版，为此她获得了</span><span style="font-size: 12pt;">2011</span><span style="font-family: DengXian; font-size: 12pt;">柯琳文学奖。</span><span style="font-size: 12pt;">2019</span><span style="font-family: DengXian; font-size: 12pt;">年秘鲁政府授予她高级军官的杰出服务奖。<br /></span></p><img src ="http://www.cppblog.com/Chipset/aggbug/217779.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2021-08-13 21:17 <a href="http://www.cppblog.com/Chipset/archive/2021/08/13/217779.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>What does “stride” mean in image processing? [fwd]</title><link>http://www.cppblog.com/Chipset/archive/2021/07/12/217739.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Mon, 12 Jul 2021 07:00:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2021/07/12/217739.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/217739.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2021/07/12/217739.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/217739.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/217739.html</trackback:ping><description><![CDATA[<div><a href="https://medium.com/@oleg.shipitko/what-does-stride-mean-in-image-processing-bba158a72bcd">https://medium.com/@oleg.shipitko/what-does-stride-mean-in-image-processing-bba158a72bcd</a></div><p style="margin-top:.1in;margin-right:0in;margin-bottom:0in; margin-left:0in;margin-bottom:.0001pt;line-height:42.0pt;"><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">Stride is an important concept in digital image processing. It allows performing several operations with an image in a very fast manner (in constant time) by simple modification of image metadata. If you are interested in finding out what stride is and how to use it stick with us.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><strong><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">Pixel representation in a computer memory</span></strong></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">Before we dive into the concept of stride we first need to revise how digital images are stored in a computer memory. We will start from a pixel.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">An image pixel is&nbsp;represented in a computer memory by a fixed number of bits. Typical pixel<strong><em>&nbsp;bit depth</em></strong>&nbsp;(amount of bits per pixel) is 32, 16, 8 or, for binary images, 1 bit. In typical RGB images, 8 bits are often used to store the color value </span><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,serif;Times New Roman&quot;;color:#292929;letter-spacing:-.05pt">&#8203;&#8203;</span><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">of a single channel. Thus, the total</span>&nbsp;<strong><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;; color:#292929;letter-spacing:-.05pt">bit depth</span></em></strong><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">&nbsp;of one pixel is 24. Processing 32 and 16-bit chunks of data is simple and effective on a typical 32 and 64-bit processors. Therefore, the pixels are stored in the format of 32 bits, where the older (or younger, depending on the implementation) 8 bits remain unused. Such an approach to storing pixels requires more memory, but it allows speeding up image processing by using the standard size of the machine word. Thus, a standard RGB image occupies 32 bits in memory and has a&nbsp;<strong><em>depth</em></strong>&nbsp;of 24 bits. We will call another 8 bits necessary to supplement the size of the memory occupied by a pixel to the value of a multiple of degree 2,&nbsp;<strong><em>pixel padding</em></strong>. The total number of bytes occupied by a pixel in memory is called&nbsp;<strong><em>pixel stride</em></strong>&nbsp;(See Image 1).</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><strong><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">Image representation in a computer memory</span></strong></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">Images are stored in computer memory pixel-by-pixel, line by line. The upper left corner of the image is usually chosen as a coordinate origin (the upper left pixel of the image has the index [0, 0]). The image is stored in memory as a one-dimensional array. Pixels of the first line of the image are first written to the memory, then pixels of the second line and so on up to the last line. Each line in addition to the pixel bytes may also contain additional bytes &#8212;&nbsp;<strong><em>line padding</em></strong>. Additional bytes usually do not contain useful information and do not affect the visualization of an image when, for example, displayed on the screen. These additional bytes serve to complement a line, which is necessary for more efficient image processing and is caused by the specificity of the hardware used. For example, Cairo (a popular open source vector graphics software library) requires alignment of rows to multiple 4 bytes, which allows for more efficient image processing algorithms using vectorized processor operations and processing several image pixels simultaneously.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">Introducing the term of&nbsp;<strong><em>line padding&nbsp;</em></strong>requires to introduce another closely coupled term &#8212;&nbsp;<strong><em>line stride</em></strong>.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><strong><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">Line stride</span></em></strong><span style="font-size:12.0pt; font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929;letter-spacing:-.05pt">&nbsp;(<strong><em>increment</em></strong>,&nbsp;<strong><em>pitch</em></strong>&nbsp;or&nbsp;<strong><em>step size</em></strong>) is the number of bytes that one needs to add to the address in the first pixel of a row in order to go to the address of the first pixel of the next row. It is important to note that an image<strong><em>&nbsp;width</em></strong>&nbsp;is measured in pixels and describes an image itself (and doesn&#8217;t depend on how an image is stored in a computer memory). In contrast, a&nbsp;<strong><em>line stride</em></strong>&nbsp;depends on how an image is represented in memory and is measured in bytes.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">In program source code, an image is usually represented by a data structure containing metadata (image<strong><em>&nbsp;width&nbsp;</em></strong>and&nbsp;<strong><em>height</em></strong>,&nbsp;<strong><em>line stride</em></strong><em>,&nbsp;<strong>number of channels</strong>,&nbsp;<strong>encoding type</strong></em>, etc.), as well as a pointer to the address of the first image pixel in memory (further we will refer to this address as&nbsp;<strong><em>data_begin</em></strong>). This information allows us to unambiguously read and decode an image from memory, as well as to perform a series of fast image operations by changing only a metadata associated with an image.</span></p>  <p style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"><img src="http://www.cppblog.com/images/cppblog_com/chipset/image_stride.png" width="808" height="346" alt="" /><br /></p>  <p style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,serif;Times New Roman&quot;">An image representation in a computer memory. Lines of an image are stored one by one in one-dimensional array.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><strong><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">Image operations:<br /></span></strong><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">Let&#8217;s summarize all the terms which we introduced to this moment:<br /></span><strong><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">pixel_address</span></em></strong><em>&nbsp;</em><span style="font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">&#8212; a pixel address in memory<br /></span><strong><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">pixel depth</span></em></strong><span style="font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">&nbsp;&#8212;the number of bits per pixel (containing valuable information)<br /></span><strong><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">pixel_stride</span></em></strong><span style="font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">&nbsp;&#8212; the number of bytes occupied in memory by a pixel of an image<br /></span><strong><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">data_begin</span></em></strong><span style="font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">&nbsp;&#8212; the address of the first image pixel in memory<br /></span><strong><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">channels</span></em></strong><em>&nbsp;</em><span style="font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">&#8212; the number of image channels (3 for an RGB-image)<br /></span><strong><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">channel_address &#8212;&nbsp;</span></em></strong><span style="font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">the address of a particular pixel channel in memory<br /></span><strong><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">height</span></em></strong><span style="font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">&nbsp;&#8212; the image height in pixels<br /></span><strong><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">width</span></em></strong><span style="font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">&nbsp;&#8212; the image width in pixels<br /></span><strong><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">line_stride</span></em></strong><em>&nbsp;</em><span style="font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">&#8212; the number of bytes occupied in memory by a line of an image</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">Operations:</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:70.5pt;margin-bottom:.0001pt;text-indent:-.25in;line-height: 24.0pt;"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;color:#292929;letter-spacing:-.05pt">1.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><strong><span style="font-size:12.0pt;font-family: &quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929;letter-spacing:-.05pt">Computing pixel address in memory</span></strong></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">The equation relating pixel memory address to its coordinates [y, x] in the image coordinate system can be represented as:</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">pixel_address = data_begin + y * line_stride + x * pixel_stride, (1)<br /></span></em><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">where&nbsp;</span><em style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">data_begin &#8212;&nbsp;</em><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">the address of the first image pixel in memory.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">Equation (1) is used whenever you access an image in memory. In the rest of operations, presented in this post, we will only change a metadata associated with an image and assume, that the equation (1) is applied after in order to access image.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">2.<strong>&nbsp;Pixel decoding</strong>&nbsp;(for RGB image with an equal amount of bits per channel):</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">channel_address = pixel_address + n * depth / channels, (2)<br /></span></em><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">where&nbsp;</span><em style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">n&nbsp;</em><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">is a channel index:&nbsp;</span><em style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">n = 0, 1, &#8230;, channels &#8212; 1</em><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">. Thus, for instance, for the typical RGB-image with an equal amount of bits per channel, a channel address in memory can be computed as follows:<br /></span><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">R = pixel_address,<br /></span></em><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">G = pixel_address + depth / channels,<br /></span></em><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">B = pixel_address + 2 * depth / channels.</span></em></p><p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">It is important to note that these equations depend on the type of the image stored. There are formats in which different number of bytes is used to store different channels.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">3.<strong>&nbsp;Image flip</strong></span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">3.1&nbsp;<strong>Vertical flip<br /></strong></span><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">data_begin = data_begin + (height- 1) * line_stride ,<br /></span></em><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">line_stride = -line_stride.</span></em></p>  <p style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"><img src="http://www.cppblog.com/images/cppblog_com/chipset/vertical_flip.png" width="700" height="246" alt="" /><br /></p>  <p style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,serif;Times New Roman&quot;">Pointer to the first image pixel for the vertical flip</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">The negative&nbsp;<strong><em>line stride</em></strong>&nbsp;being inserted into equation (1) allows us to move upwards reading (or visualizing) an image from the last row to the first, thus, realizing vertical flip.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">3.2&nbsp;<strong>Horizontal flip<br /></strong></span><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">data_begin = data_begin + (width &#8212; 1) * pixel_stride ,<br /></span></em><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">pixel_stride = -pixel_stride.</span></em></p>  <p style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;background:#F2F2F2"><span style="font-family: &quot;Times New Roman&quot;, serif; font-size: 12pt;"><img src="http://www.cppblog.com/images/cppblog_com/chipset/horizontal_flip.png" width="700" height="310" alt="" /><br />Pointer to the first image pixel for the horizontal flip</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">In the same manner as with negative&nbsp;<strong><em>line stride</em>&nbsp;</strong>in the previous example, the negative&nbsp;<strong><em>pixel stride&nbsp;</em></strong>here allows us to move from right to left and to read (or visualize) an image flipped horizontally.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">3.3&nbsp;<strong>Vertical and horizontal flip<br /></strong></span><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">The combination of previous two approaches allows to flip an image in both directions at once:<br /></span><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">data_begin = data_begin + (height-1) * line_stride + (width-1) * pixel_stride,<br /></span></em><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">line_stride = -line_stride,<br /></span></em><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">pixel_stride = -pixel_stride.</span></em></p>  <p style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;background:#F2F2F2">&nbsp;<img src="http://www.cppblog.com/images/cppblog_com/chipset/horizontal_flip2.png" width="700" height="276" alt="" /><br /><span style="font-family: &quot;Times New Roman&quot;, serif; font-size: 12pt;">Pointer to the first image pixel for the simultaneous vertical and horizontal flip</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">4.<strong>&nbsp;Extracting image subwindow<br /></strong></span><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">data_begin = new_data_begin,<br /></span></em><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">width = new_width,<br /></span></em><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">height = new_height.<br /></span></em><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">With this approach we set a new origin of our image (inside a boundary of the original image) and set a&nbsp;</span><em style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">width</em><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">&nbsp;and&nbsp;</span><em style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">height&nbsp;</em><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">which basically tell us how many time we should apply an equation (1) to read all pixels (</span><strong style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;"><em>width</em></strong><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">&nbsp;x&nbsp;</span><strong style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;"><em>height</em></strong><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">) and after which amount of pixels read we should increase the y coordinate (to start reading pixels of the next row). Note that such parameters as&nbsp;</span><strong style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;"><em>line stride&nbsp;</em></strong><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">remain unchanged.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">5.&nbsp;<strong>Extracting single image channel<br /></strong></span><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">To extract a single image channel we can use a combination of equations (1) and (2):<br /></span><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">pixel_address = data_begin + y * line_stride + x * pixel_stride +</span></em><em><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">&nbsp;n * depth / channels,<br /></span></em><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">where&nbsp;</span><em style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">n &#8212;&nbsp;</em><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">channel index,&nbsp;</span><em style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">n = 0, 1, &#8230;, channels &#8212; 1</em><span style="color: #292929; font-family: Georgia, serif; font-size: 12pt; letter-spacing: -0.05pt;">.</span></p>  <p style="margin-top:24.0pt;margin-right:0in;margin-bottom: 0in;margin-left:0in;margin-bottom:.0001pt;line-height:24.0pt"><strong><span style="font-size:12.0pt;font-family:&quot;Georgia&quot;,serif;Times New Roman&quot;;Times New Roman&quot;;color:#292929; letter-spacing:-.05pt">REFERENCES<br /></span></strong><span style="text-indent: -0.25in; font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">1.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="text-indent: -0.25in; font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">A programmer&#8217;s view on digital images: the essentials:&nbsp;<a href="https://www.collabora.com/news-and-blog/blog/2016/02/16/a-programmers-view-on-digital-images-the-essentials/"><span style="color:blue">https://www.collabora.com/news-and-blog/blog/2016/02/16/a-programmers-view-on-digital-images-the-essentials/<br /></span></a></span><span style="text-indent: -0.25in; font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">2.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="text-indent: -0.25in; font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">Microsoft Media Foundation Programming Guide: Image Stride:<a href="https://docs.microsoft.com/en-us/windows/desktop/medfound/image-stride"><span style="color:blue">Image Stride When a video image is stored in memory, the memory buffer might contain extra padding bytes after each row of pixels&#8230;docs.microsoft.com<br /></span></a></span><span style="text-indent: -0.25in; font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">3.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="text-indent: -0.25in; font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">Wikipedia: Stride of an array:&nbsp;<a href="https://en.wikipedia.org/wiki/Stride_of_an_array"><span style="color: blue">https://en.wikipedia.org/wiki/Stride_of_an_array<br /></span></a></span><span style="text-indent: -0.25in; font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">4.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="text-indent: -0.25in; font-size: 12pt; font-family: Georgia, serif; color: #292929; letter-spacing: -0.05pt;">Cairo library:&nbsp;<a href="https://cairographics.org/"><span style="color:blue">https://cairographics.org/</span></a></span></p><img src ="http://www.cppblog.com/Chipset/aggbug/217739.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2021-07-12 15:00 <a href="http://www.cppblog.com/Chipset/archive/2021/07/12/217739.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>raster and vector image [fwd]</title><link>http://www.cppblog.com/Chipset/archive/2021/07/09/217733.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Fri, 09 Jul 2021 12:13:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2021/07/09/217733.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/217733.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2021/07/09/217733.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/217733.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/217733.html</trackback:ping><description><![CDATA[<div><span style="font-size: 12pt;">转载的，出处不详。<br /><br /><strong>Raster Images</strong></span></div><div>&#160;<img src="http://www.cppblog.com/images/cppblog_com/chipset/raster.png" width="397" height="207" alt="" /></div><div>Raster (or bitmap) images are generally what you think about when thinking of images. These are the types of images that are produced when scanning or photographing an object. Raster images are compiled using pixels, or tiny dots, containing unique color and tonal information that come together to create the image.&#160;</div><div>Since raster images are pixel based, they are resolution dependent. The number of pixels that make up an image as well as how many of those pixels are displayed per inch, both determine the quality of an image. As you may have guessed, the more pixels in the image and the higher the resolution is, the higher quality the image will be.</div><div>For example, if we scale a raster image to enlarge it, without changing resolution, it will lose quality and look blurry or pixilated. This is because we are stretching the pixels over a larger area, thus making them look less sharp. This is a common problem but can be remedied by using raster image editing programs such as Photoshop to change resolution and properly scale images.</div><div>&#160;</div><div>Common Raster Image Types: JPG, TIFF, GIF, PNG, BMP</div><div>&#160;<img src="http://www.cppblog.com/images/cppblog_com/chipset/color.png" width="1150" height="121" alt="" /></div><div><br /><strong style="font-size: 12pt;">Vector Images</strong></div><div>&#160;<img src="http://www.cppblog.com/images/cppblog_com/chipset/vector.png" width="397" height="207" alt="" /></div><div>Instead of trying to keep track of the millions of tiny pixels in a raster image, vector images, or line art, keep track of points and the equations for the lines that connect them. Generally speaking, vector images are made up of paths or line art that can infinitely scalable because they work based on algorithms rather than pixels.</div><div>&#160;</div><div>One of the greatest things about vector images is that you can re-size them infinitely larger or smaller, and they will still print out just as clearly, with no increase (or decrease) in file size. If you remember back to your high school geometry, the equation for a circle of center (h,k) and radius r is (x - h)2 + (y - k)2 = r2. If you want to make the circle bigger, you just increase the value of r - instead of having to keep track of tons more pixels, the computer just has to keep track of a different number. That takes almost no file space at all.</div><div>So, what types of graphics would typically be vector? Well, almost all computer font files are based on vector images of the letters - that's why it's possible to scale them WAY up or WAY down and still have the letters be clear.&#160; All Microsoft Office clipart uses vector art and most charts and graphs produced by Office or by statistical analysis software are vector-based. Typically vector art is created in illustration applications such as Adobe Illustrator or CorelDRAW. Vector illustrations are great for logos, illustrations/artwork, animations, and text.&#160;</div><div>Common Vector File Types: EPS, SVG<br /><img src="http://www.cppblog.com/images/cppblog_com/chipset/line.png" width="473" height="82" alt="" /></div> <img src ="http://www.cppblog.com/Chipset/aggbug/217733.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2021-07-09 20:13 <a href="http://www.cppblog.com/Chipset/archive/2021/07/09/217733.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Base64</title><link>http://www.cppblog.com/Chipset/archive/2021/06/22/217717.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Tue, 22 Jun 2021 09:54:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2021/06/22/217717.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/217717.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2021/06/22/217717.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/217717.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/217717.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 转自：https://github.com/ReneNyffenegger/cpp-base64 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->/*&nbsp;&nbsp;&nbsp;base64.cpp&nbsp;and&nbsp;base64.h...&nbsp;&nbsp;<a href='http://www.cppblog.com/Chipset/archive/2021/06/22/217717.html'>阅读全文</a><img src ="http://www.cppblog.com/Chipset/aggbug/217717.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2021-06-22 17:54 <a href="http://www.cppblog.com/Chipset/archive/2021/06/22/217717.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>留学加拿大</title><link>http://www.cppblog.com/Chipset/archive/2020/07/06/217394.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Mon, 06 Jul 2020 01:49:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2020/07/06/217394.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/217394.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2020/07/06/217394.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/217394.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/217394.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 转自知乎，不对真实性负责。基本基于现实生活，细节有加工。原先写这个答案，只是想调侃一下当年我自己和周围同学们留学以及之后移民的经历，因为想着以英文字母代替真实人名，所以只写了不到26个老同学的小故事，但写完后发现太偏颇，都是小留学生转移民的案例，不足以代表广大成年工作后再来到加拿大的技术移民，投资移民，甚至灰色一点的，难民，偷渡客，所以补充了一些故事。但这样一来字母就不够用了，我就用他们的外号或者...&nbsp;&nbsp;<a href='http://www.cppblog.com/Chipset/archive/2020/07/06/217394.html'>阅读全文</a><img src ="http://www.cppblog.com/Chipset/aggbug/217394.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2020-07-06 09:49 <a href="http://www.cppblog.com/Chipset/archive/2020/07/06/217394.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PDF里的BOX</title><link>http://www.cppblog.com/Chipset/archive/2020/03/02/217178.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Mon, 02 Mar 2020 09:01:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2020/03/02/217178.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/217178.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2020/03/02/217178.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/217178.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/217178.html</trackback:ping><description><![CDATA[<p style="margin-top:6.0pt;margin-right:0in;margin-bottom:0in; margin-left:0in;margin-bottom:.0001pt;line-height:normal;"><span style="font-size:24.0pt;font-family:&quot;Comic Sans MS&quot;;Times New Roman&quot;;Times New Roman&quot;;">The PDF page boxes: MediaBox, CropBox, BleedBox, TrimBox &amp; ArtBox</span></p>  <p style="margin-bottom:.1in;line-height:normal;background: white"><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">A PDF describes the content and appearance of one or more pages. It also contains a definition of the physical size of those pages. That page size definition is not as straightforward as you might think. There can in fact be up to 5 different definitions in a PDF that relate to the size of its pages. These are called the&nbsp;<strong>boundary boxes</strong>&nbsp;or page boxes:</span></p>  <p style="margin-left: 12pt; text-indent: -0.25in; line-height: normal; background: white;"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 11.5pt; font-family: Arial, sans-serif;">The&nbsp;<strong>MediaBox</strong>&nbsp;is used to specify the width and height of the page. For the average user, this probably equals the actual page size. For prepress use, this is not the case as we prefer our pages to be defined slightly oversized so that we can see the bleed (Images or other elements touching an outer edge of a printed page need to extend beyond the edge of the paper to compensate for inaccuracies in trimming the page), the crop marks and useful information such as the file name or the date and time when the file was created. This means that PDF files used in graphic arts usually have a MediaBox which is larger than the trimmed page size.</span></p>  <p style=" margin-left:12.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">The&nbsp;<strong>CropBox</strong>&nbsp;defines the region that the PDF viewer application is expected to display or print. So if a PDF contains a CropBox definition, Acrobat uses it for screen display and printing. For prepress use, the CropBox is pretty irrelevant. The GWG industry association recommends not to use it at all.</span></p>  <p style=" margin-left:12.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">The&nbsp;<strong>TrimBox</strong>&nbsp;defines the intended dimensions of the finished page. Contrary to the CropBox, the TrimBox is very important because it defines the actual page size that gets printed. The imposition programs and workflows that I know all use the TrimBox as the basis for positioning pages on a press sheet. By default the TrimBox equals the CropBox.</span></p>  <p style=" margin-left:12.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">The&nbsp;<strong>BleedBox</strong>&nbsp;determines the region to which the page contents needs to be clipped when output in a production environment. Usually the BleedBox is 3 to 5 millimeters larger than the TrimBox. It is nice to know the size of the BleedBox but it isn&#8217;t that important in graphic arts. Most prepress systems allow you to define the amount of bleed yourself and ignore the BleedBox. By default the BleedBox equals the CropBox.</span></p>  <p style=" margin-left:12.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">The&nbsp;<strong>ArtBox&nbsp;</strong>is a bit of a special case. It was originally added to indicate the area covered by the artwork of the page. It is never used for that but can be handy in a few cases:</span></p>  <p style=" margin-left:30.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">On a PDF page that contains an advertisement, the ArtBox can be used to define the location of that ad. This allows you to place that PDF on another page but only use the area covered by the advert.</span></p>  <p style=" margin-left:30.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">A more common use of the ArtBox is as a means to indicate the safety zone. When creating a poster that will be placed in a lightbox, the designer must make sure text and logo&#8217;s aren&#8217;t positioned too close to the edge. If the poster is not mounted properly, this could cause that text or logo to disappear behind the frame of the lightbox. In book design, there is also a margin where you cannot put text because the binding might make it difficult to read text that is too close to the spine. The area where it is safe to place graphic elements is called the safety zone or text safe area. The ArtBox can be used to indicate the dimensions of this part of the page.</span></p>  <p style="margin-top:8.4pt;margin-right:0in;margin-bottom:0in; margin-left:0in;margin-bottom:.0001pt;line-height:normal;background:white"><span style="font-family: &quot;Comic Sans MS&quot;; font-size: 18.5pt; text-align: center;"><img src="http://www.cppblog.com/images/cppblog_com/chipset/pdfbox.png" width="1140" height="1416" alt="" /><br />General rules regarding page boxes</span></p>  <p style=" margin-left:12.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">Each page in a PDF can have different sizes for the various page boxes.</span></p>  <p style=" margin-left:12.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">The page boxes are always rectangular. That may seem logical but artwork is not always rectangular: a PDF can represent an oval label or the foldout of a cardboard box.</span></p>  <p style=" margin-left:12.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">A PDF always has a MediaBox definition. All the other page boxes do not necessarily have to be present in regular PDF files.</span></p>  <p style=" margin-left:12.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">The above rule is not true for the PDF/X file formats:</span></p>  <p style=" margin-left:30.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">PDF/X-1a and PDF/X-3 compliant files need to include the MediaBox, TrimBox, and BleedBox.</span></p>  <p style=" margin-left:30.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040"><a href="https://www.prepressure.com/pdf/basics/pdfx-4"><strong><span style="color: purple">PDF/X-4</span></strong></a>&nbsp;files need, next to the MediaBox, a TrimBox or an ArtBox, but not both. The ArtBox or TrimBox cannot be larger that the BleedBox. If a CropBox is present, the ArtBox,&nbsp; TrimBox, and BleedBox need to extend beyond its boundaries.</span></p>  <p style=" margin-left:12.0pt;text-indent:-.25in;line-height:normal;background:white"><span style="font-size:10.0pt;font-family:Symbol;color:#404040">&#183;<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">The MediaBox is the largest page box in a PDF. The other page boxes can equal the size of the MediaBox but they are not expected to be larger (The latter is explicitly required in the PDF/X-4 requirements). If they are larger, the PDF viewer will use the values of the MediaBox.</span></p>  <p style="margin-top:8.4pt;margin-right:0in;margin-bottom:0in; margin-left:0in;margin-bottom:.0001pt;line-height:normal;background:white"><span style="font-family: &quot;Comic Sans MS&quot;; font-size: 18.5pt;">BBox</span></p>  <p style="line-height:normal;background:white"><span style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;Times New Roman&quot;;color:#404040">Within PDF files there is another box, the bounding box or BBox, that is used. The bounding box is a rectangular frame that determines the dimensions of an object (such as a graphic, font or pattern) that is placed inside a PDF document. As such, this box has nothing to do with the page boxes.</span></p><img src ="http://www.cppblog.com/Chipset/aggbug/217178.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2020-03-02 17:01 <a href="http://www.cppblog.com/Chipset/archive/2020/03/02/217178.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>编译器预定义的宏</title><link>http://www.cppblog.com/Chipset/archive/2016/10/26/214357.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Wed, 26 Oct 2016 01:01:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2016/10/26/214357.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/214357.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2016/10/26/214357.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/214357.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/214357.html</trackback:ping><description><![CDATA[<h2><div><span style="font-size: 10pt;">源自：https://sourceforge.net/p/predef/wiki/Architectures/</span></div><br /></h2><h2>Architectures                                          <small>                                                                          </small>                                      </h2>                                                                                    <p>Please send updates/corrections to <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#112;&#114;&#101;&#100;&#101;&#102;&#45;&#99;&#111;&#110;&#116;&#114;&#105;&#98;&#117;&#116;&#101;&#64;&#108;&#105;&#115;&#116;&#115;&#46;&#115;&#111;&#117;&#114;&#99;&#101;&#102;&#111;&#114;&#103;&#101;&#46;&#110;&#101;&#116;">predef-contribute</a>.</p> <h2><a href="http://en.wikipedia.org/wiki/DEC_Alpha" rel="nofollow">Alpha</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__alpha__</code></td> <td>Defined by GNU C</td> </tr> <tr> <td>Version</td> <td><code>__alpha_ev'V'__</code></td> <td>V = Version</td> </tr> <tr> <td>Identification</td> <td><code>__alpha</code></td> <td>Defined by DEC C</td> </tr> <tr> <td>Identification</td> <td><code>_M_ALPHA</code></td> <td>Defined by Visual Studio</td> </tr> </tbody> </table> <h5>Example</h5> <table> <thead> <tr> <th>CPU</th> <th>Macro</th> </tr> </thead> <tbody> <tr> <td>Alpha EV4</td> <td><code>__alpha_ev4__</code></td> </tr> <tr> <td>Alpha EV5</td> <td><code>__alpha_ev5__</code></td> </tr> <tr> <td>Alpha EV6</td> <td><code>__alpha_ev6__</code></td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/Amd64" rel="nofollow">AMD64</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__amd64__</code><br /><code>__amd64</code><br /><code>__x86_64__</code><br /><code>__x86_64</code><br /></td> <td>Defined by GNU C and Sun Studio</td> </tr> <tr> <td>Identification</td> <td>_M_X64<br /><code>_M_AMD64</code></td> <td>Defined by Visual Studio</td> </tr> </tbody> </table> <p>Notice that <a href="http://en.wikipedia.org/wiki/X32_ABI" rel="nofollow">x32</a> can be detected by checking if the CPU uses the <a href="https://sourceforge.net/p/predef/wiki/DataModels/">ILP32 data model</a>.</p> <h2><a href="http://en.wikipedia.org/wiki/ARM_architecture" rel="nofollow">ARM</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__arm__</code></td> <td>Defined by GNU C and RealView</td> </tr> <tr> <td>Identification</td> <td><code>__thumb__</code></td> <td>Defined by GNU C and RealView in Thumb mode</td> </tr> <tr> <td>Version</td> <td><code>__ARM_ARCH_'V'__</code></td> <td>V = Version<br /><br />Defined by GNU C <a href="http://wiki.ubuntu.com/ARM/Thumb2PortingHowto" rel="nofollow">1</a></td> </tr> <tr> <td>Identification</td> <td><code>__TARGET_ARCH_ARM</code><br /><code>__TARGET_ARCH_THUMB</code></td> <td>Defined by RealView</td> </tr> <tr> <td>Version</td> <td><code>__TARGET_ARCH_ARM</code> = V<br /><code>__TARGET_ARCH_THUMB</code> = V</td> <td>V = Version</td> </tr> <tr> <td>Version</td> <td><code>__TARGET_ARCH_'VR'</code></td> <td>VR = Version and Revision</td> </tr> <tr> <td>Identification</td> <td><code>_ARM</code></td> <td>Defined by ImageCraft C</td> </tr> <tr> <td>Identification</td> <td><code>_M_ARM</code></td> <td>Defined by Visual Studio</td> </tr> <tr> <td>Identification</td> <td><code>_M_ARMT</code></td> <td>Defined by Visual Studio in Thumb mode</td> </tr> <tr> <td>Version</td> <td><code>_M_ARM</code> = V</td> <td>V = Version</td> </tr> <tr> <td>Identification</td> <td><code>__arm</code></td> <td>Defined by Diab</td> </tr> </tbody> </table> <h5>Example</h5> <table> <thead> <tr> <th>CPU</th> <th>Macro</th> <th><code>_M_ARM</code></th> </tr> </thead> <tbody> <tr> <td>ARM 2</td> <td><code>__ARM_ARCH_2__</code></td> <td><br /></td> </tr> <tr> <td>ARM 3</td> <td><code>__ARM_ARCH_3__</code><br /><code>__ARM_ARCH_3M__</code></td> <td><br /></td> </tr> <tr> <td>ARM 4T</td> <td><code>__ARM_ARCH_4T__</code><br /><code>__TARGET_ARM_4T</code></td> <td><br /></td> </tr> <tr> <td>ARM 5</td> <td><code>__ARM_ARCH_5__</code><br /><code>__ARM_ARCH_5E__</code></td> <td>5</td> </tr> <tr> <td>ARM 5T</td> <td><code>__ARM_ARCH_5T__</code><br /><code>__ARM_ARCH_5TE__</code><br /><code>__ARM_ARCH_5TEJ__</code></td> <td><br /></td> </tr> <tr> <td>ARM 6</td> <td><code>__ARM_ARCH_6__</code><br /><code>__ARM_ARCH_6J__</code><br /><code>__ARM_ARCH_6K__</code><br /><code>__ARM_ARCH_6Z__</code><br /><code>__ARM_ARCH_6ZK__</code></td> <td>6</td> </tr> <tr> <td>ARM 6T2</td> <td><code>__ARM_ARCH_6T2__</code></td> <td><br /></td> </tr> <tr> <td>ARM 7</td> <td><code>__ARM_ARCH_7__</code><br /><code>__ARM_ARCH_7A__</code><br /><code>__ARM_ARCH_7R__</code><br /><code>__ARM_ARCH_7M__</code><br /><code>__ARM_ARCH_7S__</code></td> <td>7</td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/ARM64" rel="nofollow">ARM64</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__aarch64__</code></td> <td>Defined by GNU C <a href="http://gcc.gnu.org/viewcvs/trunk/gcc/config/aarch64/aarch64.h?view=markup" rel="nofollow">1</a></td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/Blackfin" rel="nofollow">Blackfin</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__bfin</code><br /><code>__BFIN__</code></td> <td>Defined by GNU C</td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/Convex_Computer" rel="nofollow">Convex</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__convex__</code></td> <td>Defined by GNU C</td> </tr> <tr> <td>Version</td> <td><code>__convex_'V'__</code></td> <td>V = Version</td> </tr> </tbody> </table> <h5>Example</h5> <table> <thead> <tr> <th>CPU</th> <th>Macro</th> </tr> </thead> <tbody> <tr> <td>Convex C1</td> <td><code>__convex_c1__</code></td> </tr> <tr> <td>Convex C2</td> <td><code>__convex_c2__</code></td> </tr> <tr> <td>Convex C32xx series</td> <td><code>__convex_c32__</code></td> </tr> <tr> <td>Convex C34xx series</td> <td><code>__convex_c34__</code></td> </tr> <tr> <td>Convex C38xx series</td> <td><code>__convex_c38__</code></td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/Adapteva" rel="nofollow">Epiphany</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th><br /></th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__epiphany__</code></td> <td><br /></td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/PA-RISC_family" rel="nofollow">HP/PA RISC</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__hppa__</code></td> <td>Defined by GNU C</td> </tr> <tr> <td>Identification</td> <td><code>__HPPA__</code></td> <td>Defined by Stratus VOS C</td> </tr> <tr> <td>Identification</td> <td><code>__hppa</code></td> <td><br /></td> </tr> <tr> <td>Version</td> <td><code>_PA_RISC'V'_'R'</code></td> <td>V = Version<br />R = Revision</td> </tr> </tbody> </table> <p>See also <a href="http://www.openpa.net" rel="nofollow">OpenPA.net</a>.</p> <h5>Example</h5> <table> <thead> <tr> <th>CPU</th> <th>Macro</th> </tr> </thead> <tbody> <tr> <td>PA RISC 1.0</td> <td><code>_PA_RISC1_0</code></td> </tr> <tr> <td>PA RISC 1.1</td> <td><code>_PA_RISC1_1</code><br /><code>__HPPA11__</code><br /><code>__PA7100__</code></td> </tr> <tr> <td>PA RISC 2.0</td> <td><code>_PA_RISC2_0</code><br /><code>__RISC2_0__</code><br /><code>__HPPA20__</code><br /><code>__PA8000__</code></td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/X86" rel="nofollow">Intel x86</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Format</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>i386</code><br /><code>__i386</code><br /><code>__i386__</code></td> <td><br /></td> <td>Defined by GNU C</td> </tr> <tr> <td>Version</td> <td><code>__i386__</code><br /><code>__i486__</code><br /><code>__i586__</code><br /><code>__i686__</code></td> <td><br /></td> <td>Defined by GNU C</td> </tr> <tr> <td>Identification</td> <td><code>__i386</code></td> <td><br /></td> <td>Defined by Sun Studio</td> </tr> <tr> <td>Identification</td> <td><code>__i386</code><br /><code>__IA32__</code></td> <td><br /></td> <td>Defined by Stratus VOS C</td> </tr> <tr> <td>Identification</td> <td><code>_M_I86</code></td> <td><br /></td> <td>Only defined for 16-bits architectures<br /><br />Defined by Visual Studio, Digital Mars, and Watcom C/C++ (see note below)</td> </tr> <tr> <td>Identification</td> <td><code>_M_IX86</code></td> <td><br /></td> <td>Only defined for 32-bits architectures<br /><br />Defined by Visual Studio, Intel C/C++, Digital Mars, and Watcom C/C++</td> </tr> <tr> <td>Version</td> <td><code>_M_IX86</code></td> <td>V00</td> <td>V = Version</td> </tr> <tr> <td>Identification</td> <td><code>__X86__</code></td> <td><br /></td> <td>Defined by Watcom C/C++</td> </tr> <tr> <td>Identification</td> <td><code>_X86_</code></td> <td><br /></td> <td>Defined by MinGW32</td> </tr> <tr> <td>Identification</td> <td><code>__THW_INTEL__</code></td> <td><br /></td> <td>Defined by XL C/C++</td> </tr> <tr> <td>Identification</td> <td><code>__I86__</code></td> <td><br /></td> <td>Defined by Digital Mars</td> </tr> <tr> <td>Version</td> <td><code>__I86__</code></td> <td>V</td> <td>V = Version</td> </tr> <tr> <td>Identification</td> <td><code>__INTEL__</code></td> <td><br /></td> <td>Defined by CodeWarrior</td> </tr> <tr> <td>Identification</td> <td><code>__386</code></td> <td><br /></td> <td>Defined by Diab</td> </tr> </tbody> </table> <p>Notice that Watcom C/C++ defines <code>_M_IX86</code> for both 16-bits and 32-bits architectures. Use <code>__386__</code> or <code>_M_I386</code> to detect 32-bits architectures in this case.</p> <p>Notice that the Stratus VOS is big-endian on IA32, so these macros cannot be used to detect endianness if <code>__VOS__</code> is set.</p> <h5>Example</h5> <table> <thead> <tr> <th>CPU</th> <th><code>_M_IX86</code></th> <th><code>__I86__</code></th> </tr> </thead> <tbody> <tr> <td>80386</td> <td>300</td> <td>3</td> </tr> <tr> <td>80486</td> <td>400</td> <td>4</td> </tr> <tr> <td>Pentium</td> <td>500</td> <td>5</td> </tr> <tr> <td>Pentium Pro/II</td> <td>600</td> <td>6</td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/Itanium" rel="nofollow">Intel Itanium (IA-64)</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Format</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__ia64__</code><br /><code>_IA64</code><br /><code>__IA64__</code></td> <td><br /></td> <td>Defined by GNU C</td> </tr> <tr> <td>Identification</td> <td><code>__ia64</code></td> <td><br /></td> <td>Defined by HP aCC</td> </tr> <tr> <td>Identification</td> <td><code>_M_IA64</code></td> <td><br /></td> <td>Defined by Visual Studio</td> </tr> <tr> <td>Identification</td> <td><code>_M_IA64</code></td> <td><br /></td> <td>Defined by Intel C/C++</td> </tr> <tr> <td>Version</td> <td><code>_M_IA64</code></td> <td>?</td> <td><br /></td> </tr> <tr> <td>Identification</td> <td><code>__itanium__</code></td> <td><br /></td> <td>Defined by Intel C/C++</td> </tr> </tbody> </table> <h5>Example</h5> <table> <thead> <tr> <th>CPU</th> <th><code>_M_IA64</code> (Intel C/C++)</th> </tr> </thead> <tbody> <tr> <td><br /></td> <td>64100</td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/M68k" rel="nofollow">Motorola 68k</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__m68k__</code></td> <td>Defined by GNU C</td> </tr> <tr> <td>Version</td> <td><code>__mc'V'__</code><br /><code>__mc'V'</code><br /><code>mc'V'</code></td> <td>V = Version</td> </tr> <tr> <td>Identification</td> <td><code>M68000</code></td> <td>Defined by SAS/C</td> </tr> <tr> <td>Identification</td> <td><code>__MC68K__</code></td> <td>Defined by Stratus VOS C</td> </tr> <tr> <td>Version</td> <td><code>__MC'V'__</code></td> <td>V = Version</td> </tr> </tbody> </table> <h5>Example</h5> <table> <thead> <tr> <th>CPU</th> <th>Macro</th> </tr> </thead> <tbody> <tr> <td>68000</td> <td><code>__mc68000__</code><br /><code>__MC68000__</code></td> </tr> <tr> <td>68010</td> <td><code>__mc68010__</code></td> </tr> <tr> <td>68020</td> <td><code>__mc68020__</code><br /><code>__MC68020__</code></td> </tr> <tr> <td>68030</td> <td><code>__mc68030__</code><br /><code>__MC68030__</code></td> </tr> <tr> <td>68040</td> <td><code>__mc68040__</code></td> </tr> <tr> <td>68060</td> <td><code>__mc68060__</code></td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/MIPS_architecture" rel="nofollow">MIPS</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__mips__</code><br /><code>mips</code></td> <td>Defined by GNU C</td> </tr> <tr> <td>Version</td> <td><code>_MIPS_ISA</code> = <code>_MIPS_ISA_MIPS'V'</code></td> <td>V = MIPS ISA level</td> </tr> <tr> <td>Version</td> <td><code>_R3000</code><br /><code>_R4000</code><br /><code>_R5900</code></td> <td><br /></td> </tr> <tr> <td>Identification</td> <td><code>__mips</code></td> <td>Defined by MIPSpro and GNU C</td> </tr> <tr> <td>Version</td> <td><code>__mips</code></td> <td>The value indicates the MIPS ISA (Instruction Set Architecture) level</td> </tr> <tr> <td>Version</td> <td><code>__MIPS_ISA'V'__</code></td> <td>V = MIPS ISA level</td> </tr> <tr> <td>Identification</td> <td><code>__MIPS__</code></td> <td>Defined by Metrowerks</td> </tr> </tbody> </table> <h5>Example</h5> <table> <thead> <tr> <th>CPU</th> <th><code>_MIPS_ISA</code></th> <th>GNU C Macro</th> <th><code>__mips</code></th> <th>MIPSpro Macro</th> </tr> </thead> <tbody> <tr> <td>R2000</td> <td><code>_MIPS_ISA_MIPS1</code></td> <td><br /></td> <td>1</td> <td><br /></td> </tr> <tr> <td>R3000</td> <td><code>_MIPS_ISA_MIPS1</code></td> <td><code>_R3000</code></td> <td>1</td> <td><br /></td> </tr> <tr> <td>R6000</td> <td><code>_MIPS_ISA_MIPS2</code></td> <td><br /></td> <td>2</td> <td><code>__MIPS_ISA2__</code></td> </tr> <tr> <td>R4000</td> <td><br /></td> <td><code>_R4000</code></td> <td><br /></td> <td><br /></td> </tr> <tr> <td>R4400</td> <td><code>_MIPS_ISA_MIPS3</code></td> <td><br /></td> <td>3</td> <td><code>__MIPS_ISA3__</code></td> </tr> <tr> <td>R8000</td> <td><code>_MIPS_ISA_MIPS4</code></td> <td><br /></td> <td>4</td> <td><code>__MIPS_ISA4__</code></td> </tr> <tr> <td>R10000</td> <td><code>_MIPS_ISA_MIPS4</code></td> <td><br /></td> <td>4</td> <td><code>__MIPS_ISA4__</code></td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/PowerPC" rel="nofollow">PowerPC</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__powerpc</code><br /><code>__powerpc__</code><br /><code>__powerpc64__</code><br /><code>__POWERPC__</code><br /><code>__ppc__</code><br /><code>__ppc64__</code><br /><code>__PPC__</code><br /><code>__PPC64__</code><br /><code>_ARCH_PPC</code><br /><code>_ARCH_PPC64</code></td> <td>Defined by GNU C</td> </tr> <tr> <td>Version</td> <td><code>__ppc'V'__</code></td> <td>V = Version</td> </tr> <tr> <td>Identification</td> <td><code>_M_PPC</code></td> <td>Defined by Visual Studio</td> </tr> <tr> <td>Version</td> <td><code>_M_PPC</code></td> <td>?</td> </tr> <tr> <td>Identification</td> <td><code>_ARCH_PPC</code><br /><code>_ARCH_PPC64</code></td> <td>Defined by XL C/C++</td> </tr> <tr> <td>Version</td> <td><code>_ARCH_'V'</code></td> <td>V = Version</td> </tr> <tr> <td>Version</td> <td><code>__PPCGECKO__</code></td> <td><a href="javascript:void(0)" rel="nofollow">Gekko</a><br /><br />Defined by CodeWarrior</td> </tr> <tr> <td>Version</td> <td><code>__PPCBROADWAY__</code></td> <td><a href="javascript:void(0)" rel="nofollow">Broadway</a><br /><br />Defined by CodeWarrior</td> </tr> <tr> <td>Version</td> <td><code>_XENON</code></td> <td><a href="javascript:void(0)" rel="nofollow">Xenon</a></td> </tr> <tr> <td>Identification</td> <td><code>__ppc</code></td> <td>Defined by Diab</td> </tr> </tbody> </table> <h5>Example</h5> <table> <thead> <tr> <th>CPU</th> <th><code>_M_PPC</code></th> <th>Macro</th> <th>XL Macro</th> </tr> </thead> <tbody> <tr> <td>PowerPC 440</td> <td><br /></td> <td><br /></td> <td><code>_ARCH_440</code></td> </tr> <tr> <td>PowerPC 450</td> <td><br /></td> <td><br /></td> <td><code>_ARCH_450</code></td> </tr> <tr> <td>PowerPC 601</td> <td>601</td> <td><code>__ppc601__</code></td> <td><code>_ARCH_601</code></td> </tr> <tr> <td>PowerPC 603</td> <td>603</td> <td><code>__ppc603__</code></td> <td><code>_ARCH_603</code></td> </tr> <tr> <td>PowerPC 604</td> <td>604</td> <td><code>__ppc604__</code></td> <td><code>_ARCH_604</code></td> </tr> <tr> <td>PowerPC 620</td> <td>620</td> <td><br /></td> <td><br /></td> </tr> </tbody> </table> <h2>Pyramid 9810</h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>pyr</code></td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/RS/6000" rel="nofollow">RS/6000</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__THW_RS6000</code></td> <td>Defined by XL C/C++</td> </tr> <tr> <td>Identification</td> <td><code>_IBMR2</code></td> <td><br /></td> </tr> <tr> <td>Identification</td> <td><code>_POWER</code></td> <td><br /></td> </tr> <tr> <td>Identification</td> <td><code>_ARCH_PWR</code><br /><code>_ARCH_PWR2</code><br /><code>_ARCH_PWR3</code><br /><code>_ARCH_PWR4</code></td> <td><br /></td> </tr> </tbody> </table> <h1><a href="http://en.wikipedia.org/wiki/SPARC" rel="nofollow">SPARC</a></h1> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__sparc__</code></td> <td>Defined by GNU C</td> </tr> <tr> <td>Identification</td> <td><code>__sparc</code></td> <td>Defined by Sun Studio</td> </tr> <tr> <td>Version</td> <td><code>__sparc_v8__</code><br /><code>__sparc_v9__</code></td> <td>Defined by GNU C</td> </tr> <tr> <td>Version</td> <td><code>__sparcv8</code><br /><code>__sparcv9</code></td> <td>Defined by Sun Studio</td> </tr> </tbody> </table> <h5>Example</h5> <table> <thead> <tr> <th>CPU</th> <th>Sun Studio Macro</th> <th>GNU C Macro</th> </tr> </thead> <tbody> <tr> <td>SPARC v8 (SuperSPARC)</td> <td><code>__sparcv8</code></td> <td><code>__sparc_v8__</code></td> </tr> <tr> <td>SPARC v9 (UltraSPARC)</td> <td><code>__sparcv9</code></td> <td><code>__sparc_v9__</code></td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/SuperH" rel="nofollow">SuperH</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__sh__</code></td> <td>Defined by GNU C</td> </tr> <tr> <td>Version</td> <td><code>__sh1__</code><br /><code>__sh2__</code><br /><code>__sh3__</code><br /><code>__SH3__</code><br /><code>__SH4__</code><br /><code>__SH5__</code></td> <td><br /></td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/IBM_System_z" rel="nofollow">SystemZ</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__370__</code><br /><code>__THW_370__</code></td> <td>Identifies <a href="http://en.wikipedia.org/wiki/System/370" rel="nofollow">System/370</a><br /><br />Defined by XL C/C++</td> </tr> <tr> <td>Identification</td> <td><code>__s390__</code></td> <td>Identifies <a href="http://en.wikipedia.org/wiki/System/390" rel="nofollow">System/390</a><br /><br />Defined by GNU C</td> </tr> <tr> <td>Identification</td> <td><code>__s390x__</code></td> <td>Identifies <a href="http://en.wikipedia.org/wiki/Z/Architecture" rel="nofollow">z/Architecture</a><br /><br />Defined by GNU C</td> </tr> <tr> <td>Identification</td> <td><code>__zarch__</code></td> <td>Identifies <a href="http://en.wikipedia.org/wiki/Z/Architecture" rel="nofollow">z/Architecture</a><br /><br />Defined by clang</td> </tr> <tr> <td>Identification</td> <td><code>__SYSC_ZARCH__</code></td> <td>Identifies <a href="http://en.wikipedia.org/wiki/Z/Architecture" rel="nofollow">z/Architecture</a><br /><br />Defined by Systems/C</td> </tr> </tbody> </table> <h2><a href="http://en.wikipedia.org/wiki/Texas_Instruments_TMS320" rel="nofollow">TMS320</a></h2> <table> <thead> <tr> <th>Type</th> <th>Macro</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>_TMS320C2XX</code><br /><code>__TMS320C2000__</code></td> <td>C2000 series</td> </tr> <tr> <td>Identification</td> <td><code>_TMS320C5X</code><br /><code>__TMS320C55X__</code></td> <td>C5000 series</td> </tr> <tr> <td>Identification</td> <td><code>_TMS320C6X</code><br /><code>__TMS320C6X__</code></td> <td>C6000 series</td> </tr> </tbody> </table> <h5>Example</h5> <table> <thead> <tr> <th>DSP</th> <th>Macro</th> </tr> </thead> <tbody> <tr> <td>C28xx</td> <td><code>_TMS320C28X</code></td> </tr> <tr> <td>C54x</td> <td><code>_TMS320C5XX</code></td> </tr> <tr> <td>C55x</td> <td><code>__TMS320C55X__</code></td> </tr> <tr> <td>C6200</td> <td><code>_TMS320C6200</code></td> </tr> <tr> <td>C6400</td> <td><code>_TMS320C6400</code></td> </tr> <tr> <td>C6400+</td> <td><code>_TMS320C6400_PLUS</code></td> </tr> <tr> <td>C6600</td> <td><code>_TMS320C6600</code></td> </tr> <tr> <td>C6700</td> <td><code>_TMS320C6700</code></td> </tr> <tr> <td>C6700+</td> <td><code>_TMS320C6700_PLUS</code></td> </tr> <tr> <td>C6740</td> <td><code>_TMS320C6740</code></td> </tr> </tbody> </table> <h2>TMS470</h2>  <table><thead> <tr> <th>Type</th> <th>Macro</th> </tr> </thead> <tbody> <tr> <td>Identification</td> <td><code>__TMS470__</code></td></tr></tbody></table><img src ="http://www.cppblog.com/Chipset/aggbug/214357.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2016-10-26 09:01 <a href="http://www.cppblog.com/Chipset/archive/2016/10/26/214357.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>When someone gives you a bug [FWD]</title><link>http://www.cppblog.com/Chipset/archive/2015/04/01/210219.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Wed, 01 Apr 2015 06:39:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2015/04/01/210219.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/210219.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2015/04/01/210219.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/210219.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/210219.html</trackback:ping><description><![CDATA[(I'm a front-end developer, but I thought this might resonate)<br /><br />Someone gives you a bug. "The light in the conference room on the 26th floor is on. It needs to be off."<br /><br />A note on the bug says, &#8220;This will take you like 5 minutes. It's just flipping a switch."<br /><br />You go to the conference room on 26. The light is on, but there's no light switch in the room.<br /><br />So you prepare to install one. But the designer says it would ruin the room&#8217;s aesthetic. Plus, the walls are concrete. With the proper tools, you could install the switch. But no one will approve the purchase of the proper tools. Without the proper tools it will take two days. And they want it done now, because they're afraid that any minute the CEO might decide to go to the 26th floor and happen to walk by the conference room and ask why the hell that light is on.<br /><br />And now you're getting emails asking why the light isn't off yet.<br /><br />So now you have to stop and send a group email to explain the situation, and several people start up a panicked email chain.<br /><br />You know if you wait for the problem to be resolved by anyone discussing it in the email chain, it won&#8217;t get fixed. The bug has your name on it, and it's dated today, so you're the one in trouble if it isn't resolved. So you go up into the hallway ceiling on 26, find the wires leading to the light, cut and cap them. Finally. Problem solved.<br /><br />In order to quell the panic in the email thread, you report back how you solved the issue.<br /><br />You don&#8217;t hear anything for a while. When you do, everyone is concerned that now the light can&#8217;t be turned on and off. What if the CEO wants to have a meeting in there? So here&#8217;s what they ask you to do: They want you to run wires from the light down into the basement. When someone needs the light to be on or off, they&#8217;ll contact you, and have you run to the basement and either connect or disconnect the wires.<br /><br />You protest the ridiculousness of this solution. Your boss says, &#8220;Yeah, I know it&#8217;s not ideal. But it&#8217;s the only solution we have right now."<br /><br />At this point you realize you have a choice. You could do this. Or you could quit in protest, and find another job. But you realize that once you start that new job, they&#8217;re likely to ask you to do something just as idiotic, if not more so.<br /><br />So you go run the wires from floor 26 down to the basement. When you get to the basement, you see dozens of wires hanging out of the walls, from all the people who have had to do this exact same thing before. (So that&#8217;s where the idea came from.) You set up the wires and label them as best you can, with a short apology to whoever has to deal with this next.<br /><br />When you get back to your desk, you have a message. QA has reopened the bug. It says, &#8220;I see light."<br /><br />You head back up to the conference room on 26. The light is off. You go back to your desk and close the bug, reporting that you checked on it in person.<br /><br />QA reopens the bug again. &#8220;Room still lit&#8221; it says. After looking at the unlit bulb one more time, you tell your boss, who suggests you go back down to the basement and check the wires. You protest that you are looking at the light right now and it&#8217;s off. &#8220;I know, but this way you can tell QA you checked out absolutely everything."<br /><br />So you sigh and head to the basement. Sure enough, the wires are not connected. The ends are capped. They are not resting on anything that could conduct electricity.<br /><br />You report back to QA that you checked the wires, which are not connected, and that you looked at the bulb, which was unlit.<br /><br />&#8220;I didn&#8217;t mean the bulb,&#8221; says QA. &#8220;The bug is about light in the room. There&#8217;s still too much light. Shouldn&#8217;t you close the blinds?"<br /><br />You respond that the blinds don&#8217;t fall under your control, and that the bug specifies the light being turned off.<br /><br />Not believing you, QA sends out a group email asking if the blinds are covered by the bug.<br /><br />Some time passes before you hear from anyone. Finally someone from the email chain calls you.<br /><br />&#8220;Theoretically,&#8221; they ask, &#8220;could someone participating in a meeting in the conference room on 26 open or close the blinds by themselves if it was too bright or too dark?"<br /><br />Yes they could, you reply.<br /><br />&#8220;Like, an ordinary person? They wouldn&#8217;t need you to do it?"<br /><br />Yes, an ordinary person. No, they wouldn&#8217;t need you. Anyone can do it.<br /><br />&#8220;Great. Excellent. Then we&#8217;ll leave that for now. I&#8217;ll schedule a stand-up meeting about the blinds issue."<br /><br />So the bug is closed. Now, the CEO, possibly having caught wind of all the discussion and furtive activity surrounding the conference room on 26, wants to have a meeting there. You get several panicked emails that they need the light on.<br /><br />You go to the basement, connect the wires, and return to your desk, to find 32 new messages in your inbox. &#8220;Something&#8217;s wrong&#8212;the light&#8217;s not on!&#8221; &#8220;There&#8217;s a problem &#8212; no light!&#8221; &#8220;Are you getting these emails?&#8221; and so on.<br /><br />The 32nd email says, &#8220;Nevermind&#8212;the light&#8217;s on."<br /><br />This process is repeated more or less exactly when it&#8217;s time to turn the light off again.<br /><br />But if there&#8217;s any good news, it&#8217;s this: after the meeting, everyone forgets that there even is a conference room on 26, so you never have to do anything about it again.<br /><br />Wow, gold! Thanks!<img src ="http://www.cppblog.com/Chipset/aggbug/210219.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2015-04-01 14:39 <a href="http://www.cppblog.com/Chipset/archive/2015/04/01/210219.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>using gcc_x86 assembly to scan the most significant one bit and the least significant one bit</title><link>http://www.cppblog.com/Chipset/archive/2014/06/15/207298.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Sun, 15 Jun 2014 09:38:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2014/06/15/207298.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/207298.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2014/06/15/207298.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/207298.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/207298.html</trackback:ping><description><![CDATA[原来发过搜索第一位的帖子，这次算再补充一下吧。以下取自网络，作者不详。<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; ">&nbsp;1</span>&nbsp;<span style="color: #000000; ">#ifdef&nbsp;__GNUC__<br /></span><span style="color: #008080; ">&nbsp;2</span>&nbsp;<span style="color: #000000; "><br /></span><span style="color: #008080; ">&nbsp;3</span>&nbsp;<span style="color: #000000; "></span><span style="color: #0000FF; ">#if</span><span style="color: #000000; ">&nbsp;(defined&nbsp;_WIN64&nbsp;||&nbsp;defined&nbsp;__x86_64__)</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">&nbsp;4</span>&nbsp;<span style="color: #000000; "><br /></span><span style="color: #008080; ">&nbsp;5</span>&nbsp;<span style="color: #000000; "></span><span style="color: #008000; ">/*</span><span style="color: #008000; ">*<br /></span><span style="color: #008080; ">&nbsp;6</span>&nbsp;<span style="color: #008000; ">&nbsp;*&nbsp;../bit_scan_forward<br /></span><span style="color: #008080; ">&nbsp;7</span>&nbsp;<span style="color: #008000; ">&nbsp;*&nbsp;@return&nbsp;index&nbsp;(0..63)&nbsp;of&nbsp;least&nbsp;significant&nbsp;one&nbsp;bit<br /></span><span style="color: #008080; ">&nbsp;8</span>&nbsp;<span style="color: #008000; ">&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">&nbsp;9</span>&nbsp;<span style="color: #000000; ">unsigned&nbsp;bit_scan_forward(unsigned&nbsp;</span><span style="color: #0000FF; ">long</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000FF; ">long</span><span style="color: #000000; ">&nbsp;x)<br /></span><span style="color: #008080; ">10</span>&nbsp;<span style="color: #000000; ">{<br /></span><span style="color: #008080; ">11</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;&nbsp;asm(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">bsfq&nbsp;%0,&nbsp;%0</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;:&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">=r</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;(x)&nbsp;:&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">0</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;(x));<br /></span><span style="color: #008080; ">12</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;unsigned(x);<br /></span><span style="color: #008080; ">13</span>&nbsp;<span style="color: #000000; ">}<br /></span><span style="color: #008080; ">14</span>&nbsp;<span style="color: #000000; "><br /></span><span style="color: #008080; ">15</span>&nbsp;<span style="color: #000000; "></span><span style="color: #008000; ">/*</span><span style="color: #008000; ">*<br /></span><span style="color: #008080; ">16</span>&nbsp;<span style="color: #008000; ">&nbsp;*&nbsp;bit_scan_reverse<br /></span><span style="color: #008080; ">17</span>&nbsp;<span style="color: #008000; ">&nbsp;*&nbsp;@return&nbsp;index&nbsp;(0..63)&nbsp;of&nbsp;most&nbsp;significant&nbsp;one&nbsp;bit<br /></span><span style="color: #008080; ">18</span>&nbsp;<span style="color: #008000; ">&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">19</span>&nbsp;<span style="color: #000000; ">unsigned&nbsp;bit_scan_reverse(unsigned&nbsp;</span><span style="color: #0000FF; ">long</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000FF; ">long</span><span style="color: #000000; ">&nbsp;x)<br /></span><span style="color: #008080; ">20</span>&nbsp;<span style="color: #000000; ">{<br /></span><span style="color: #008080; ">21</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;&nbsp;asm(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">bsrq&nbsp;%0,&nbsp;%0</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;:&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">=r</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;(x)&nbsp;:&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">0</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;(x));<br /></span><span style="color: #008080; ">22</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;unsigned(x);<br /></span><span style="color: #008080; ">23</span>&nbsp;<span style="color: #000000; ">}<br /></span><span style="color: #008080; ">24</span>&nbsp;<span style="color: #000000; "><br /></span><span style="color: #008080; ">25</span>&nbsp;<span style="color: #000000; "></span><span style="color: #0000FF; ">#elif</span><span style="color: #000000; ">&nbsp;(defined&nbsp;_WIN32)&nbsp;||&nbsp;(defined&nbsp;__linux__)</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">26</span>&nbsp;<span style="color: #000000; "><br /></span><span style="color: #008080; ">27</span>&nbsp;<span style="color: #000000; "></span><span style="color: #008000; ">/*</span><span style="color: #008000; ">*<br /></span><span style="color: #008080; ">28</span>&nbsp;<span style="color: #008000; ">&nbsp;*&nbsp;../bit_scan_forward<br /></span><span style="color: #008080; ">29</span>&nbsp;<span style="color: #008000; ">&nbsp;*&nbsp;@return&nbsp;index&nbsp;(0..63)&nbsp;of&nbsp;least&nbsp;significant&nbsp;one&nbsp;bit<br /></span><span style="color: #008080; ">30</span>&nbsp;<span style="color: #008000; ">&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">31</span>&nbsp;<span style="color: #000000; ">unsigned&nbsp;bit_scan_forward(unsigned&nbsp;</span><span style="color: #0000FF; ">long</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000FF; ">long</span><span style="color: #000000; ">&nbsp;x)<br /></span><span style="color: #008080; ">32</span>&nbsp;<span style="color: #000000; ">{<br /></span><span style="color: #008080; ">33</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;&nbsp;asm(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">bsf&nbsp;%0,&nbsp;%0</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;:&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">=r</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;(x)&nbsp;:&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">0</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;(x));<br /></span><span style="color: #008080; ">34</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;unsigned(x);<br /></span><span style="color: #008080; ">35</span>&nbsp;<span style="color: #000000; ">}<br /></span><span style="color: #008080; ">36</span>&nbsp;<span style="color: #000000; "><br /></span><span style="color: #008080; ">37</span>&nbsp;<span style="color: #000000; "></span><span style="color: #008000; ">/*</span><span style="color: #008000; ">*<br /></span><span style="color: #008080; ">38</span>&nbsp;<span style="color: #008000; ">&nbsp;*&nbsp;bit_scan_reverse<br /></span><span style="color: #008080; ">39</span>&nbsp;<span style="color: #008000; ">&nbsp;*&nbsp;@return&nbsp;index&nbsp;(0..63)&nbsp;of&nbsp;most&nbsp;significant&nbsp;one&nbsp;bit<br /></span><span style="color: #008080; ">40</span>&nbsp;<span style="color: #008000; ">&nbsp;</span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">41</span>&nbsp;<span style="color: #000000; ">unsigned&nbsp;bit_scan_reverse(unsigned&nbsp;</span><span style="color: #0000FF; ">long</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000FF; ">long</span><span style="color: #000000; ">&nbsp;x)<br /></span><span style="color: #008080; ">42</span>&nbsp;<span style="color: #000000; ">{<br /></span><span style="color: #008080; ">43</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;&nbsp;asm(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">bsr&nbsp;%0,&nbsp;%0</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;:&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">=r</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;(x)&nbsp;:&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">0</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;(x));<br /></span><span style="color: #008080; ">44</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&nbsp;unsigned(x);<br /></span><span style="color: #008080; ">45</span>&nbsp;<span style="color: #000000; ">}<br /></span><span style="color: #008080; ">46</span>&nbsp;<span style="color: #000000; "><br /></span><span style="color: #008080; ">47</span>&nbsp;<span style="color: #000000; "></span><span style="color: #0000FF; ">#endif</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">48</span>&nbsp;<span style="color: #000000; "><br /></span><span style="color: #008080; ">49</span>&nbsp;<span style="color: #000000; "></span><span style="color: #0000FF; ">#endif</span></div><img src ="http://www.cppblog.com/Chipset/aggbug/207298.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2014-06-15 17:38 <a href="http://www.cppblog.com/Chipset/archive/2014/06/15/207298.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Is there an ISO standard for C sharp language?</title><link>http://www.cppblog.com/Chipset/archive/2011/09/27/156961.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Tue, 27 Sep 2011 06:43:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2011/09/27/156961.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/156961.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2011/09/27/156961.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/156961.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/156961.html</trackback:ping><description><![CDATA[<div>  <p><span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">今天看老外写的文章提到了</span>C#<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">国际标准</span>&#8230;</p>  <p><span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">什么，</span>C#<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">还有国际标准？不会吧？谷歌一下，果然如此，</span>06<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">年就有了</span>ISO<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">标准</span>&#8230;<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">居然还能从</span>ISO<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">官网下载到电子版。</span></p>  <p><span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">看来金钱就是好东西啊，有钱能使鬼推磨道理在地球上哪里都好用</span>&#8230;</p>  <p><span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">继续谷歌，在</span>MSDN<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">上发现了下面的文字。</span></p>  <p><span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">连接：</span>http://msdn.microsoft.com/en-us/netframework/aa569283</p>  <p>In June 2005, the General Assembly of the international standardization organization Ecma approved edition 3 of the C# Language and the Common Language Infrastructure (CLI) specifications, as updated Ecma-334 and Ecma-335, respectively (see <a href="http://www.ecma-international.org/news/PressReleases/PR_TC39_CSharp_CLI.htm">press release</a>). The updated technical report on the CLI, Ecma TR-84, and a new technical report on the CLI, Ecma TR-89, were also ratified.</p>  <p>In July 2005, Ecma submitted the Standards and TRs to ISO/IEC JTC 1 via the ISO Fast-Track process. The Standards were adopted in April 2006 as ISO/IEC 23270:2006 (C#), ISO/IEC 23270:2006 (CLI), ISO/IEC TR 23272:2006 (CLI, XML Libraries) and ISO ISO/IEC TR 25438:2006 (CLI, Common Generics).</p>  <p>In July 2006 the General Assembly of Ecma approved edition 4 of the Standards which correspond to the ISO 2006 versions.</p>  <h3>Latest Standards</h3>  <p>The following official Ecma documents are available for <a href="http://www.ecma-international.org/publications/standards/Ecma-334.htm">C#</a> and the <a href="http://www.ecma-international.org/publications/standards/Ecma-335.htm">CLI</a> (<a href="http://www.ecma-international.org/publications/techreports/E-TR-084.htm">TR-84</a>, <a href="http://www.ecma-international.org/publications/techreports/E-TR-089.htm">TR-89</a>). These links are direct from Ecma:</p>  <table border="0" cellpadding="0">  <thead>   <tr>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p><strong>&nbsp;</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p><strong>File name</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p><strong>&nbsp;</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p style="text-align:center" align="center"><strong>Size (Bytes)</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p style="text-align:center" align="center"><strong>&nbsp;</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p><strong>Content</strong></p>    </td>   </tr>  </thead>  <tbody><tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080001">   <p><a href="http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf">ECMA-334.pdf</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080003">   <p style="text-align:right" align="right">2 614 003</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080004">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080005">   <p>C# Language Specification</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080001">   <p><a href="http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-335.pdf">ECMA-335.pdf</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080003">   <p style="text-align:right" align="right">3 219 107</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080004">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080005">   <p>Common Language Infrastructure</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080001">   <p><a href="http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-335.zip">ECMA-335.zip</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080003">   <p style="text-align:right" align="right">754 982</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080004">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080005">   <p>XML-based Library Specification</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080001">   <p><a href="http://www.ecma-international.org/publications/files/ECMA-TR/TR-084.pdf">TR-084.pdf</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080003">   <p style="text-align:right" align="right">187 450</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080004">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080005">   <p>Information Derived from Partition IV XML File</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080001">   <p><a href="http://www.ecma-international.org/publications/files/ECMA-TR/TR-084.zip">TR-084.zip</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080003">   <p style="text-align:right" align="right">19 329 610</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080004">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080005">   <p>XML Tool, Libraries in Microsoft&#169; Word and PDF</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080001">   <p><a href="http://www.ecma-international.org/publications/files/ECMA-TR/TR-089.pdf">TR-089.pdf</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080003">   <p style="text-align:right" align="right">589 400</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080004">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080005">   <p>Common Generics Library</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080001">   <p><a href="http://www.ecma-international.org/publications/files/ECMA-TR/TR-089.zip">TR-089.zip</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080003">   <p style="text-align:right" align="right">461 074</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080004">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th079F6F080005">   <p>Common Generics Library Reference Implementation</p>   </td>  </tr> </tbody></table>  <p><a href="http://kahu.zoot.net.nz/ecma/index.html">Reference implementation for TR-89</a><br /> <a href="http://sourceforge.net/projects/cli-parallel">Reference implementation for the Parallel API</a></p>  <p>The official ISO/IEC documents are available from the ISO/IEC <a href="http://isotc.iso.org/livelink/livelink/fetch/2000/2489/Ittf_Home/PubliclyAvailableStandards.htm">Freely Available Standards</a> page. These links are direct from that page:</p>  <table border="0" cellpadding="0">  <thead>   <tr>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p><strong>&nbsp;</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p><strong>File name</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p><strong>&nbsp;</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p><strong>Content</strong></p>    </td>   </tr>  </thead>  <tbody><tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00001">   <p><a href="http://standards.iso.org/ittf/PubliclyAvailableStandards/c042926_ISO_IEC_23270_2006%28E%29.zip">ISO/IEC   23270:2006</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00003">   <p>Information technology -- Programming languages -- C#</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00001">   <p><a href="http://standards.iso.org/ittf/PubliclyAvailableStandards/c042927_ISO_IEC_23271_2006%28E%29.zip">ISO/IEC   23271:2006</a><br />   - <a href="http://standards.iso.org/ittf/PubliclyAvailableStandards/c042927_ISO_IEC_23271_2006%28E%29_Software.zip">Software</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00003">   <p>Information technology -- Common Language Infrastructure   (CLI)<br />   Partitions I to VI</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00001">   <p><a href="http://standards.iso.org/ittf/PubliclyAvailableStandards/c042928_ISO_IEC_TR_23272_2006%28E%29.zip">ISO/IEC   TR 23272:2006</a><br />   - Software</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00003">   <p>Information technology -- Common Language Infrastructure   (CLI)<br />   -- Technical Report on Information Derived from Partition IV XML File</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00001">   <p><a href="http://standards.iso.org/ittf/PubliclyAvailableStandards/c042925_ISO_IEC_TR_25438_2006%28E%29.zip">ISO/IEC   TR 25438:2006</a><br />   - <a href="http://standards.iso.org/ittf/PubliclyAvailableStandards/c042925_ISO_IEC_TR_25438_2006%28E%29_Software.zip">Software</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th083808D00003">   <p>Information technology -- Common Language Infrastructure   (CLI)<br />   -- Technical Report: Common Generics</p>   </td>  </tr> </tbody></table>  <h3>Current Working Draft</h3>  <p>Work on the 5th edition of Ecma-335 CLI standard began in mid-2009. The TC49-TG3 task group is working on extending both the virtual machine and class libraries of the CLI specification. In addition, improvements are being made to clarify existing elements of the specification. Many of these improvements are the result of feedback received from outside the task group, for which the task group is grateful.</p>  <p>Posted below is a snapshot of the committee's work as of 27 March 2010.</p>  <p>The participants in TC49/TG3 are providing these working documents to the public for informational purposes only. The contents are subject to change as often as once a month. To participate in the standardization process, contact your organization's Ecma representative. If your company does not currently participate in Ecma and wishes to do so, please contact <a href="http://www.ecma-international.org/">ECMA</a> directly.</p>  <p>The following organizations and contributors are actively participating in the work of TC49/TG3:<br /> Eiffel Software, Microsoft Corporation, Novell Corporation, Kahu Research, and Twin Roots.</p>  <p>Many of the organizations that are currently participating in the TC49/TG3 work have volunteered to mirror this site. The URLs for the mirror sites are:<br /> - <a href="http://www.dotnetexperts.com/ecma/">Eiffel Software</a><br /> - Microsoft Corporation<br /> - <a href="http://mono-project.com/ECMA-335-CLI-Public-Draft">Novell Corporation</a><br /> - <a href="http://kahu.zoot.net.nz/ecma/clidraft">Kahu Research</a><br /> - <a href="http://twinroots.com/ecma/cli/">Twin Roots</a></p>  <p>Available Documents (Documents current as of 27 March 2010)<br /> The following working draft documents are available:</p>  <p>- CLI Partition I - Architecture (<a href="http://download.microsoft.com/download/1/5/4/1546A0C9-A650-4CE4-B056-36EC09C4CFC0/Partition_I_Architecture.zip">word/pdf zip</a>)<br /> - CLI Partition II - Metadata and File Format (<a href="http://download.microsoft.com/download/1/5/4/1546A0C9-A650-4CE4-B056-36EC09C4CFC0/Partition_II_Metadata.zip">word/pdf zip</a>)<br /> - CLI Partition III - CIL <a href="http://download.microsoft.com/download/1/5/4/1546A0C9-A650-4CE4-B056-36EC09C4CFC0/Partition_III_CIL.zip">(word/pdf zip</a>)<br /> - CLI Partition IV - Library (<a href="http://download.microsoft.com/download/1/5/4/1546A0C9-A650-4CE4-B056-36EC09C4CFC0/Partition_IV_Library.zip">word/pdf zip</a>)<br /> - CLI Partition V - Binary Formats (<a href="http://download.microsoft.com/download/1/5/4/1546A0C9-A650-4CE4-B056-36EC09C4CFC0/Partition_V_BinaryFormats.zip">word/pdf zip</a>)<br /> - CLI Partition VI - Annexes (<a href="http://download.microsoft.com/download/1/5/4/1546A0C9-A650-4CE4-B056-36EC09C4CFC0/Partition_VI_Annexes.zip">word/pdf zip</a>)<br /> - Class Library XML (<a href="http://download.microsoft.com/download/1/5/4/1546A0C9-A650-4CE4-B056-36EC09C4CFC0/CLIClassLibraryXML.zip">xml zip</a>)<br /> - Class Library Detailed Specifications (<a href="http://download.microsoft.com/download/1/5/4/1546A0C9-A650-4CE4-B056-36EC09C4CFC0/CLIClassLibraryDocs.zip">word/pdf zip</a>)</p>  <h3>Annotated Standards</h3>  <p>Members of the Standard committees and others have combined to produce annotated versions of the Standards. These are:</p>  <ul type="disc"><li><em>The Common Language      Infrastructure Annotated Standard</em>, James S. Miller &amp; Susann      Ragsdale, Addison-Wesley, 2004, ISBN 0-321-15493-2 (based on Edition 2 of      Ecma-335)</li><li><em>C# Annotated Standard</em>,      Jon Jagger, Nigel Perry &amp; Peter Sestoft, Morgan Kaufmann, 2007, ISBN      978-0-12-372511-0 (based on Edition 4 of Ecma-334)</li></ul>  <h3>Microsoft Implementation Specific Versions</h3>  <p>The following documents are versions of the Standards with Microsoft implementation-specific notes added. These notes provide extra information about Microsoft's Common Language Runtime (CLR) implementation of the CLI.</p>  <table border="0" cellpadding="0">  <thead>   <tr>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p><strong>&nbsp;</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p><strong>File name</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p><strong>&nbsp;</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p style="text-align:center" align="center"><strong>Size (Bytes)</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p style="text-align:center" align="center"><strong>&nbsp;</strong></p>    </td>    <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt">    <p><strong>Content</strong></p>    </td>   </tr>  </thead>  <tbody><tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880001">   <p><a href="http://download.microsoft.com/download/7/3/3/733AD403-90B2-4064-A81E-01035A7FE13C/MS%20Partition%20I.pdf">MS   Partition I.pdf</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880003">   <p style="text-align:right" align="right">815 983</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880004">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880005">   <p>Common Language Infrastructure, Partition I: Concepts and   Architecture</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880001">   <p><a href="http://download.microsoft.com/download/7/3/3/733AD403-90B2-4064-A81E-01035A7FE13C/MS%20Partition%20II.pdf">MS   Partition II.pdf</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880003">   <p style="text-align:right" align="right">1 758 195</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880004">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880005">   <p>Common Language Infrastructure, Partition II: Metadata   Definition and Semantics</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880001">   <p><a href="http://download.microsoft.com/download/7/3/3/733AD403-90B2-4064-A81E-01035A7FE13C/MS%20Partition%20III.pdf">MS   Partition III.pdf</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880003">   <p style="text-align:right" align="right">661 414</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880004">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880005">   <p>Common Language Infrastructure, Partition III: CIL   Instruction Set</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880001">   <p><a href="http://download.microsoft.com/download/7/3/3/733ad403-90b2-4064-a81e-01035a7fe13c/MS%20Partition%20IV.pdf">MS   Partition IV.pdf</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880003">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880004">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880005">   <p>Common Language Infrastructure, Partition IV: Profiles and   Libraries</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880001">   <p><a href="http://download.microsoft.com/download/7/3/3/733ad403-90b2-4064-a81e-01035a7fe13c/MS%20Partition%20V.pdf">MS   Partition V.pdf</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880003">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880004">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880005">   <p>Common Language Infrastructure, Partition V: Binary   Formats</p>   </td>  </tr>  <tr>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880000">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880001">   <p><a href="http://download.microsoft.com/download/7/3/3/733ad403-90b2-4064-a81e-01035a7fe13c/MS%20Partition%20VI.pdf">MS   Partition VI.pdf</a></p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880002">   <p>&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880003">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880004">   <p style="text-align:right" align="right">&nbsp;</p>   </td>   <td style="padding:1.5pt 1.5pt 1.5pt 1.5pt" headers="th08436E880005">   <p><span>Common Language   Infrastructure, Partition VI: Annexes</span></p>   </td>  </tr> </tbody></table>  <h4>The Ecma 4<sup>th</sup> and ISO 2<sup>nd</sup> Editions</h4>  <p>Aside from bug fixes, major enhancements from previous editions include:</p>  <h4>CLI</h4>  <ul type="disc"><li>First-class support for      generics at the runtime and class library level</li><li>An API to help developers      begin multithreaded and parallel programming</li><li>Enhancements to the Common      Intermediate Language (CIL) and Common Language Specification (CLS)</li><li>An interchangeable debug      format</li></ul>  <h4>C#</h4>  <ul type="disc"><li>First-class language support      for generics</li><li>Anonymous methods</li><li>Iterators</li><li>Nullable Types</li></ul>  <h3>Previous Editions Background</h3>  <p>In August, 2000, Microsoft Corporation, Hewlett-Packard and Intel Corporation co-sponsored the submission of specifications for the Common Language Infrastructure (CLI) and C# programming language to the international standardization organization Ecma. As a result, Ecma formed two task groups (TG3 and TG2, respectively) within TC39, its technical committee responsible for programming languages and application development.</p>  <p>During the next year, the co-sponsor companies, in conjunction with other Ecma members and guests (including IBM, Fujitsu Software, Plum Hall, Monash University and ISE), refined these specifications into standards. In December, 2001, the Ecma General Assembly ratified the 1<sup>st</sup> edition of the C# and CLI standards as Ecma-334 and Ecma-335, respectively. A technical report on the CLI, Ecma TR-84, was also ratified.</p>  <p>In late December, 2001, Ecma submitted the standards and TR to ISO/IEC JTC 1 via the latter's Fast-Track process. The subsequent 6-month evaluation and comment period resulted in two NO votes (Japan and UK) on the draft standards, and one NO vote (Japan) on the draft TR. All comments resulting from this review were considered at a ballot resolution meeting held in October, 2002. The two NO votes on the standards were resolved, making acceptance unanimous. However, Japan did not change its NO vote on the draft TR (Japan would like to see a formatted/readable rendering of the CLI class library as part of the standard, not as a TR; this will be considered for a future edition).</p>  <p>The ISO/IEC standards and TR were published in April, 2003, and are known formally as ISO/IEC 23270 (C#), ISO/IEC 23271 (CLI) and ISO/IEC 23272 (CLI TR). Equivalent specifications were adopted as 2<sup>nd</sup> edition standards and TR by Ecma at its December, 2002, General Assembly.</p>  <h3>Joining Ecma</h3>  <p>To participate in the standardization process, contact your organization&#8217;s Ecma representative. If your company does not currently participate in Ecma and wishes to do so, please <a href="http://www.ecma-international.org/">contact Ecma</a> directly.</p>  <h3>Acknowledgements</h3>  <p>The following organizations have participated in the work of Ecma TC39/TG2 and TC39/TG3 and their contributions are gratefully acknowledged: Borland, Fujitsu, Hewlett-Packard, Intel Corporation, International Business Machines, ISE, IT University Copenhagen, JSL (UK), Kahu Research (New Zealand), Microsoft Corporation, Monash University, Netscape, Novell Corporation, OpenWave, Plum Hall, Sun Microsystems.</p>  <p>Many of the organizations that have participated in the TC39/TG2 and TC39/TG3 work have volunteered to mirror this site. The links for the mirror sites are:</p>  <ul type="disc"><li>Intel Corporation</li><li><a href="http://www.dotnetexperts.com/ecma">ISE (Eiffel)</a></li><li><a href="http://www.itu.dk/people/sestoft/ecma/">IT University, Copenhagen</a></li><li><a href="http://kahu.zoot.net.nz/ecma">Kahu Research, New Zealand</a></li><li>Microsoft Corporation</li><li><a href="http://www.mono-project.com/index.php?title=ECMA">Novell (Mono)</a></li></ul>  <p><br /></p>  </div><img src ="http://www.cppblog.com/Chipset/aggbug/156961.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2011-09-27 14:43 <a href="http://www.cppblog.com/Chipset/archive/2011/09/27/156961.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个母亲一生的8个谎言(转)</title><link>http://www.cppblog.com/Chipset/archive/2011/09/07/155267.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Wed, 07 Sep 2011 03:12:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2011/09/07/155267.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/155267.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2011/09/07/155267.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/155267.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/155267.html</trackback:ping><description><![CDATA[<div><p style="text-indent: 2em;">转贴，已经记不清出处，抱歉。</p><p style="text-indent: 2em;"><br /></p><p style="text-indent: 2em">1、儿时，小男孩家很穷，吃饭时，饭常常不够吃，母亲就把自己碗里的饭分给孩子吃。母亲说，孩子们，快吃吧，我不饿！&#8212;&#8212;母亲撒的第一个谎 </p> <p style="text-indent: 2em">　　 </p> <p style="text-indent: 2em">2、男孩长身体的时候，勤劳的母亲常用周日休息时间去县郊农村河沟里捞些鱼来给孩子们补钙。鱼 很好吃，鱼汤也很鲜。孩子们吃鱼的时候，母亲就在一旁啃鱼骨头，用舌头舔鱼骨头上的肉渍。男孩心疼，就把自己碗里的鱼夹到母亲碗里，请母亲吃鱼。母亲不 吃，母亲又用筷子把鱼夹回男孩的碗里。母亲说，孩子，快吃吧，我不爱吃鱼！&#8212;&#8212;母亲撒的第二个谎 </p> <p style="text-indent: 2em">　　 </p> <p style="text-indent: 2em">3、上初中了，为了缴够男孩和哥姐的学费，当缝纫工的母亲就去居委会领些火柴盒拿回家来，晚上 糊了挣点分分钱补点家用。有个冬天，男孩半夜醒来，看到母亲还躬着身子在油灯下糊火柴盒。男孩说，母亲，睡了吧，明早您还要上班呢。母亲笑笑，说，孩子， 快睡吧，我不困！&#8212;&#8212;母亲撒的第三个谎 </p> <p style="text-indent: 2em">　　 </p> <p style="text-indent: 2em">4、高考那年，母亲请了假天天站在考点门口为参加高考的男孩助阵。时逢盛夏，烈日当头，固执的 母亲在烈日下一站就是几个小时。考试结束的铃声响了，母亲迎上去递过一杯用罐头瓶泡好的浓茶叮嘱孩子喝了，茶亦浓，情更浓。望着母亲干裂的嘴唇和满头的汗 珠，男孩将手中的罐头瓶反递过去请母亲喝。母亲说，孩子，快喝吧，我不渴！&#8212;&#8212;母亲撒的四个谎 </p> <p style="text-indent: 2em">　　 </p> <p style="text-indent: 2em">5、父亲病逝之后，母亲又当爹又当娘，靠着自己在缝纫社里那点微薄收入含辛茹苦拉扯着几个孩 子，供他们念书，日子过得苦不堪言。胡同路口电线杆下修表的李叔叔知道后，大事小事就找岔过来打个帮手，搬搬煤，挑挑水，送些钱粮来帮补男孩的家里。人非 草木，孰能无情。左邻右舍对此看在眼里，记在心里，都劝母亲再嫁，何必苦了自己。然而母亲多年来却守身如玉，始终不嫁，别人再劝，母亲也断然不听，母亲 说，我不爱！&#8212;&#8212;撒的五个谎 </p> <p style="text-indent: 2em">　　 </p> <p style="text-indent: 2em">6、男孩和她的哥姐大学毕业参加工作后，下了岗的母亲就在附近农贸市场摆了个小摊维持生活。身在外地工作的孩子们知道后就常常寄钱回来补贴母亲，母亲坚决不要，并将钱退了回去。母亲说，我有钱！&#8212;&#8212;撒的六个谎 </p> <p style="text-indent: 2em">　　 </p> <p style="text-indent: 2em">7、男孩留校任教两年，后又考取了美国一所名牌大学的博士生，毕业后留在美国一家科研机构工作，待遇相当丰厚，条件好了，身在异国的男孩想把母亲接来享享清福却被老人回绝了。母亲说，我不习惯！&#8212;&#8212;撒的七个谎 </p> <p style="text-indent: 2em">　　 </p> <p style="text-indent: 2em">8、晚年，母亲患了胃癌，住进了医院，远在大西洋彼岸的男孩乘飞机赶回来时，术后的母亲已是奄奄一息了。母亲老了，望着被病魔折磨得死去活来的母亲，男孩悲痛欲绝，潸然泪下。母亲却说，孩子，别哭，我不疼。&#8212;&#8212;撒的最后一个谎</p></div><img src ="http://www.cppblog.com/Chipset/aggbug/155267.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2011-09-07 11:12 <a href="http://www.cppblog.com/Chipset/archive/2011/09/07/155267.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>查找一个64位整数二进制第一个1</title><link>http://www.cppblog.com/Chipset/archive/2011/08/23/154114.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Tue, 23 Aug 2011 04:41:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2011/08/23/154114.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/154114.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2011/08/23/154114.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/154114.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/154114.html</trackback:ping><description><![CDATA[<div> 		<div>  <p><span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">有时候用到位运算。需要快速找到一个整数的二进制第一个</span>1<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">或</span>0<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">在哪个位</span>(<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">下标</span>)<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">？例如：十进制数</span>100<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">的二进制是</span>1100100<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">，那么它的第一个</span>1<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">在下标</span> <span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">为</span>2<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">的位置</span>(bsf, bit scan forward)<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">或</span>6<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">的位置</span>(bsr, bit scan in reverse order)<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">，由于只用于存储一个状态，至于用</span>bsf<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">还是</span>bsr<span style="font-family: SimSun;">则无所谓。</span><br /> <br /> <span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">解决这个问题的第一个想法就是用内联汇编的做法，使用特别的</span>CPU<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">指令去找，但汇编的可移植性比较差，不同的</span>CPU<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">型号使用的指令可能不一样，执行速度也不一样。</span><br /> <span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">假设找一个</span>64<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">位无符号整数二进制的第一个</span>1<span style="font-family: SimSun;Times New Roman&quot;;Times New Roman&quot;">，用</span>bsf, AT&amp; T<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">汇编</span>(gcc<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">汇编</span>)<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">可以这样做：</span></p>  <p style="background:#EEEEEE;word-break:break-all"><span style="font-size:10.0pt;color:teal">&nbsp;1</span><span style="font-size:10.0pt">&nbsp;<span style="color:green">//&nbsp;bit&nbsp;scan&nbsp;forward&nbsp;for&nbsp;64&nbsp;bit&nbsp;integral&nbsp;number<br /> </span><span style="color:teal">&nbsp;2</span>&nbsp;<span style="color:green">/*&nbsp;============================================&nbsp;*/</span><span style="color:black"><br /> </span><span style="color:teal">&nbsp;3</span>&nbsp;<span style="color:black">inline&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;bsf_asm&nbsp;(uint64_t&nbsp;w)<br /> </span><span style="color:teal">&nbsp;4</span>&nbsp;<span style="color:black">{<br /> </span><span style="color:teal">&nbsp;5</span>&nbsp;<span style="color:black">&nbsp;&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;x1,&nbsp;x2;<br /> </span><span style="color:teal">&nbsp;6</span>&nbsp;<span style="color:black">&nbsp;&nbsp;asm&nbsp;("bsf&nbsp;%0,%0\n"&nbsp;"jnz&nbsp;1f\n"&nbsp;"bsf&nbsp;%1,%0\n"&nbsp;"jz&nbsp;1f\n"&nbsp;"addl&nbsp;$32,%0\n"<br /> </span><span style="color:teal">&nbsp;7</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"1:":&nbsp;"=&amp;q"&nbsp;(x1),&nbsp;"=&amp;q"&nbsp;(x2):"1"&nbsp;((</span><span style="color:blue">int</span><span style="color:black">)&nbsp;(w&nbsp;&gt;&gt;&nbsp;32)),<br /> </span><span style="color:teal">&nbsp;8</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"0"&nbsp;((</span><span style="color:blue">int</span><span style="color:black">)&nbsp;w));<br /> </span><span style="color:teal">&nbsp;9</span>&nbsp;<span style="color:black">&nbsp;&nbsp;</span><span style="color:blue">return</span><span style="color:black">&nbsp;x1;<br /> </span><span style="color:teal">10</span>&nbsp;<span style="color:black">}</span></span></p>  <p><br /> <span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">如果用</span>C<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">来实现的话，那就有点麻烦了，在此不讲复杂的数学原理，仅仅给出代码。</span></p>  <p style="background:#EEEEEE"><span style="font-size:10.0pt; color:teal">&nbsp;1</span><span style="font-size:10.0pt">&nbsp;<span style="color:green">//&nbsp;bit&nbsp;scan&nbsp;forward&nbsp;for&nbsp;64&nbsp;bit&nbsp;integral&nbsp;number<br /> </span><span style="color:teal">&nbsp;2</span>&nbsp;<span style="color:green">/*&nbsp;============================================&nbsp;*/</span><span style="color:black"><br /> </span><span style="color:teal">&nbsp;3</span>&nbsp;<span style="color:black">inline&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;bsf_folded&nbsp;(uint64_t&nbsp;bb)<br /> </span><span style="color:teal">&nbsp;4</span>&nbsp;<span style="color:black">{<br /> </span><span style="color:teal">&nbsp;5</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:blue">static</span>&nbsp;<span style="color:blue">const</span>&nbsp;<span style="color:blue">int</span><span style="color:black">&nbsp;lsb_64_table[64]&nbsp;=<br /> </span><span style="color:teal">&nbsp;6</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;{<br /> </span><span style="color:teal">&nbsp;7</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;63,&nbsp;30,&nbsp;&nbsp;3,&nbsp;32,&nbsp;59,&nbsp;14,&nbsp;11,&nbsp;33,<br /> </span><span style="color:teal">&nbsp;8</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;60,&nbsp;24,&nbsp;50,&nbsp;&nbsp;9,&nbsp;55,&nbsp;19,&nbsp;21,&nbsp;34,<br /> </span><span style="color:teal">&nbsp;9</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;61,&nbsp;29,&nbsp;&nbsp;2,&nbsp;53,&nbsp;51,&nbsp;23,&nbsp;41,&nbsp;18,<br /> </span><span style="color:teal">10</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;56,&nbsp;28,&nbsp;&nbsp;1,&nbsp;43,&nbsp;46,&nbsp;27,&nbsp;&nbsp;0,&nbsp;35,<br /> </span><span style="color:teal">11</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;62,&nbsp;31,&nbsp;58,&nbsp;&nbsp;4,&nbsp;&nbsp;5,&nbsp;49,&nbsp;54,&nbsp;&nbsp;6,<br /> </span><span style="color:teal">12</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;15,&nbsp;52,&nbsp;12,&nbsp;40,&nbsp;&nbsp;7,&nbsp;42,&nbsp;45,&nbsp;16,<br /> </span><span style="color:teal">13</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;25,&nbsp;57,&nbsp;48,&nbsp;13,&nbsp;10,&nbsp;39,&nbsp;&nbsp;8,&nbsp;44,<br /> </span><span style="color:teal">14</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;20,&nbsp;47,&nbsp;38,&nbsp;22,&nbsp;17,&nbsp;37,&nbsp;36,&nbsp;26<br /> </span><span style="color:teal">15</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;};<br /> </span><span style="color:teal">16</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;unsigned&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;folded;<br /> </span><span style="color:teal">17</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;bb&nbsp;^=&nbsp;bb&nbsp;-&nbsp;1;<br /> </span><span style="color:teal">18</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;folded&nbsp;=&nbsp;(</span><span style="color:blue">int</span><span style="color:black">)&nbsp;bb&nbsp;^&nbsp;(bb&nbsp;&gt;&gt;&nbsp;32);<br /> </span><span style="color:teal">19</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;</span><span style="color:blue">return</span><span style="color:black">&nbsp;lsb_64_table[folded&nbsp;*&nbsp;0x78291ACF&nbsp;&gt;&gt;&nbsp;26];<br /> </span><span style="color:teal">20</span>&nbsp;<span style="color:black">}</span></span></p>  <p><br /> <span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">如果想从后往前搜索一个整数的二进制第一个</span>1<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">的下标，用汇编可以这样做。</span></p>  <p style="background:#EEEEEE;word-break:break-all"><span style="font-size:10.0pt;color:teal">&nbsp;1</span><span style="font-size:10.0pt">&nbsp;<span style="color:green">//&nbsp;bit&nbsp;scan&nbsp;in&nbsp;reverse&nbsp;order&nbsp;for&nbsp;64&nbsp;bit&nbsp;integral&nbsp;number<br /> </span><span style="color:teal">&nbsp;2</span>&nbsp;<span style="color:green">/*&nbsp;============================================&nbsp;*/</span><span style="color:black"><br /> </span><span style="color:teal">&nbsp;3</span>&nbsp;<span style="color:black">inline&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;bsr_asm&nbsp;(uint64_t&nbsp;w)<br /> </span><span style="color:teal">&nbsp;4</span>&nbsp;<span style="color:black">{<br /> </span><span style="color:teal">&nbsp;5</span>&nbsp;<span style="color:black">&nbsp;&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;x1,&nbsp;x2;<br /> </span><span style="color:teal">&nbsp;6</span>&nbsp;<span style="color:black">&nbsp;&nbsp;asm&nbsp;("bsr&nbsp;%1,%0\n"&nbsp;"jnz&nbsp;1f\n"&nbsp;"bsr&nbsp;%0,%0\n"&nbsp;"subl&nbsp;$32,%0\n"<br /> </span><span style="color:teal">&nbsp;7</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"1:&nbsp;addl&nbsp;$32,%0\n":&nbsp;"=&amp;q"&nbsp;(x1),&nbsp;"=&amp;q"&nbsp;(x2):"1"&nbsp;((</span><span style="color:blue">int</span><span style="color:black">)&nbsp;(w&nbsp;&gt;&gt;&nbsp;32)),<br /> </span><span style="color:teal">&nbsp;8</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"0"&nbsp;((</span><span style="color:blue">int</span><span style="color:black">)&nbsp;w));<br /> </span><span style="color:teal">&nbsp;9</span>&nbsp;<span style="color:black">&nbsp;&nbsp;</span><span style="color:blue">return</span><span style="color:black">&nbsp;x1;<br /> </span><span style="color:teal">10</span>&nbsp;<span style="color:black">}</span></span></p>  <p><br /> <span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">如果用</span>C<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">来实现的话，也比较简单，用</span>divide and conquer <span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">的原理就不会太慢。</span></p>  <p style="background:#EEEEEE"><span style="font-size:10.0pt; color:teal">&nbsp;1</span><span style="font-size:10.0pt">&nbsp;<span style="color:green">//&nbsp;a&nbsp;logn&nbsp;(n&nbsp;==&nbsp;32)algorithm&nbsp;for&nbsp;bit&nbsp;scan&nbsp;in&nbsp;reverse&nbsp;order<br /> </span><span style="color:teal">&nbsp;2</span>&nbsp;<span style="color:green">/*&nbsp;============================================&nbsp;*/</span><span style="color:black"><br /> </span><span style="color:teal">&nbsp;3</span>&nbsp;<span style="color:black">inline&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;bsr32(uint32_t&nbsp;bb)<br /> </span><span style="color:teal">&nbsp;4</span>&nbsp;<span style="color:black">{<br /> </span><span style="color:teal">&nbsp;5</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:blue">static</span>&nbsp;<span style="color:blue">const</span>&nbsp;<span style="color:blue">char</span><span style="color:black">&nbsp;msb_256_table[256]&nbsp;=<br /> </span><span style="color:teal">&nbsp;6</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;{<br /> </span><span style="color:teal">&nbsp;7</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,&nbsp;0,&nbsp;1,&nbsp;1,&nbsp;2,&nbsp;2,&nbsp;2,&nbsp;2,&nbsp;3,&nbsp;3,&nbsp;3,&nbsp;3,&nbsp;3,&nbsp;3,&nbsp;3,&nbsp;3,<br /> </span><span style="color:teal">&nbsp;8</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4,&nbsp;4,&nbsp;4,&nbsp;4,&nbsp;4,&nbsp;4,&nbsp;4,&nbsp;4,4,&nbsp;4,&nbsp;4,&nbsp;4,4,&nbsp;4,&nbsp;4,&nbsp;4,<br /> </span><span style="color:teal">&nbsp;9</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,&nbsp;5,<br /> </span><span style="color:teal">10</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,<br /> </span><span style="color:teal">11</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,&nbsp;6,<br /> </span><span style="color:teal">12</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,<br /> </span><span style="color:teal">13</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,<br /> </span><span style="color:teal">14</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,<br /> </span><span style="color:teal">15</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,&nbsp;7,<br /> </span><span style="color:teal">16</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;};<br /> </span><span style="color:teal">17</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;result&nbsp;=&nbsp;0;<br /> </span><span style="color:teal">18</span>&nbsp;<span style="color:black"><br /> </span><span style="color:teal">19</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;</span><span style="color:blue">if</span><span style="color:black">&nbsp;(bb&nbsp;&gt;&nbsp;0xFFFF)<br /> </span><span style="color:teal">20</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br /> </span><span style="color:teal">21</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bb&nbsp;&gt;&gt;=&nbsp;16;<br /> </span><span style="color:teal">22</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;+=&nbsp;16;<br /> </span><span style="color:teal">23</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;}<br /> </span><span style="color:teal">24</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;</span><span style="color:blue">if</span><span style="color:black">&nbsp;(bb&nbsp;&gt;&nbsp;0xFF)<br /> </span><span style="color:teal">25</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br /> </span><span style="color:teal">26</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bb&nbsp;&gt;&gt;=&nbsp;8;<br /> </span><span style="color:teal">27</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;+=&nbsp;8;<br /> </span><span style="color:teal">28</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;}<br /> </span><span style="color:teal">29</span>&nbsp;<span style="color:black"><br /> </span><span style="color:teal">30</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;</span><span style="color:blue">return</span><span style="color:black">&nbsp;(result&nbsp;+&nbsp;msb_256_table[bb]);<br /> </span><span style="color:teal">31</span>&nbsp;<span style="color:black">}<br /> </span><span style="color:teal">32</span>&nbsp;<span style="color:black"><br /> </span><span style="color:teal">33</span>&nbsp;<span style="color:green">/*&nbsp;============================================&nbsp;*/</span><span style="color:black"><br /> </span><span style="color:teal">34</span>&nbsp;<span style="color:black">inline&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;bsr_in_C(uint64_t&nbsp;bb)<br /> </span><span style="color:teal">35</span>&nbsp;<span style="color:black">{<br /> </span><span style="color:teal">36</span>&nbsp;<span style="color:black">&nbsp;&nbsp;</span><span style="color:blue">const</span><span style="color:black">&nbsp;uint32_t&nbsp;hb&nbsp;=&nbsp;bb&nbsp;&gt;&gt;&nbsp;32;<br /> </span><span style="color:teal">37</span>&nbsp;<span style="color:black">&nbsp;&nbsp;</span><span style="color:blue">return</span><span style="color:black">&nbsp;hb&nbsp;?&nbsp;32&nbsp;+&nbsp;bsr32((uint32_t)hb)&nbsp;:&nbsp;bsr32((uint32_t)bb);<br /> </span><span style="color:teal">38</span>&nbsp;<span style="color:black"><br /> </span><span style="color:teal">39</span>&nbsp;<span style="color:black">}<br /> </span><span style="color:teal">40</span>&nbsp;</span></p>  <p><br /> <span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">下面这个似乎也可以，失败时返回</span>-1023<span style="font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;">，至于速度快慢就要看编译器的嗜好了。</span></p>  <p style="background:#EEEEEE;word-break:break-all"><span style="font-size:10.0pt;color:teal">&nbsp;1</span><span style="font-size:10.0pt">&nbsp;<span style="color:green">//&nbsp;bit&nbsp;scan&nbsp;in&nbsp;reverse&nbsp;order&nbsp;for&nbsp;64&nbsp;bit&nbsp;integral&nbsp;number<br /> </span><span style="color:teal">&nbsp;2</span>&nbsp;<span style="color:green">/*&nbsp;============================================&nbsp;*/</span><span style="color:black"><br /> </span><span style="color:teal">&nbsp;3</span>&nbsp;<span style="color:black">inline&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;bsr_double&nbsp;(uint64_t&nbsp;bb)<br /> </span><span style="color:teal">&nbsp;4</span>&nbsp;<span style="color:black">{<br /> </span><span style="color:teal">&nbsp;5</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;union<br /> </span><span style="color:teal">&nbsp;6</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;{<br /> </span><span style="color:teal">&nbsp;7</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:blue">double</span><span style="color:black">&nbsp;d;<br /> </span><span style="color:teal">&nbsp;8</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:blue">struct</span><span style="color:black"><br /> </span><span style="color:teal">&nbsp;9</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br /> </span><span style="color:teal">10</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;mantissal&nbsp;:&nbsp;32;<br /> </span><span style="color:teal">11</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;mantissah&nbsp;:&nbsp;20;<br /> </span><span style="color:teal">12</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;exponent&nbsp;:&nbsp;11;<br /> </span><span style="color:teal">13</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;</span><span style="color:blue">int</span><span style="color:black">&nbsp;sign&nbsp;:&nbsp;1;<br /> </span><span style="color:teal">14</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br /> </span><span style="color:teal">15</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;}&nbsp;ud;<br /> </span><span style="color:teal">16</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;ud.d&nbsp;=&nbsp;(</span><span style="color:blue">double</span><span style="color:black">)(bb&nbsp;&amp;&nbsp;~(bb&nbsp;&gt;&gt;&nbsp;32));<br /> </span><span style="color:teal">17</span>&nbsp;<span style="color:black">&nbsp;&nbsp;&nbsp;</span><span style="color:blue">return</span><span style="color:black">&nbsp;ud.exponent&nbsp;-&nbsp;1023;<br /> </span><span style="color:teal">18</span>&nbsp;<span style="color:black">}<br /> </span><span style="color:teal">19</span>&nbsp;</span></p>  <span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;;"><br /> </span><span style="font-size:12.0pt;font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;;Times New Roman&quot;;">以上</span><span style="font-size:12.0pt;font-family: &quot;Times New Roman&quot;;">uint64_t</span><span style="font-size:12.0pt;font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;;Times New Roman&quot;;">和</span><span style="font-size:12.0pt;font-family: &quot;Times New Roman&quot;;">uint32_t</span><span style="font-size:12.0pt;font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;;Times New Roman&quot;;">是新</span><span style="font-size:12.0pt;font-family: &quot;Times New Roman&quot;;">C++</span><span style="font-size:12.0pt;font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;;Times New Roman&quot;;">标准可以支持的整型，分别相当于</span><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;;">旧的unsigned long long</span><span style="font-size:12.0pt; font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;;Times New Roman&quot;;">和</span><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;;">unsigned long</span><span style="font-size:12.0pt;font-family: SimSun;Times New Roman&quot;;Times New Roman&quot;;Times New Roman&quot;;">类型。<span style="color:blue">以上代码不是我的原创，而是来自国外某位朋友，我稍微加工了一下贴到这里，版权属于原作者，如果我没有记错的话应该是</span></span><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;;color:blue;">GNU</span><span style="font-size:12.0pt; font-family:SimSun;Times New Roman&quot;;Times New Roman&quot;;Times New Roman&quot;;">。</span></div></div><img src ="http://www.cppblog.com/Chipset/aggbug/154114.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2011-08-23 12:41 <a href="http://www.cppblog.com/Chipset/archive/2011/08/23/154114.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>慈善的是心而不是钱</title><link>http://www.cppblog.com/Chipset/archive/2011/08/19/153849.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Fri, 19 Aug 2011 06:47:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2011/08/19/153849.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/153849.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2011/08/19/153849.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/153849.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/153849.html</trackback:ping><description><![CDATA[<div><p style="line-height: 150%; margin-top: 0px; text-indent: 24px; margin-bottom: 0px"><span style="font-family: 仿宋_GB2312">2007年初，刚刚卸任的联合国秘书长安南，在德克萨斯州的一个庄园里举行了一场慈善晚宴，旨在为非洲贫困儿童募捐。应邀参加晚宴的都是富商和社会名流。在晚宴将要开始的时候，一位老妇人领着一个小女孩来到了庄园的入口处，小女孩手里捧着一个看上去很精致的瓷罐。</span></p> <p style="line-height: 150%; margin-top: 0px; text-indent: 24px; margin-bottom: 0px"><span style="font-family: 仿宋_GB2312; color: #333333">&nbsp;守在庄园入口处的保安安东尼拦住了这一老一小。&#8220;欢迎你们，请出示请柬，谢谢。&#8221;。</span></p> <p style="line-height: 150%; margin-top: 0px; text-indent: 24px; margin-bottom: 0px"><span style="font-family: 仿宋_GB2312; color: #333333">&#8220;请柬，对不起，我们没有接到邀请，是她要来，我陪她来的。&#8221;老妇人抚摸着小女孩的头。</span></p> <p style="line-height: 150%; margin-top: 0px; text-indent: 24px; margin-bottom: 0px"><span style="font-family: 仿宋_GB2312; color: #333333">&nbsp;&#8220;很抱歉，除了工作人员，没有请柬的人不能进去。&#8221;安东尼说。</span></p> <p style="line-height: 150%; margin-top: 0px; text-indent: 24px; margin-bottom: 0px"><span style="font-family: 仿宋_GB2312; color: #333333">&#8220;为什么？这里不是举行慈善晚宴吗？我们是来表示我们的心意的，难道不可以吗？&#8221;老妇人的表情很严肃，&#8220;可爱的小露西，从电视上知道了这里要为非洲的孩子们举行慈善活动，她很想为那些可怜的孩子做点事，决定把自己储钱罐里所有的钱都拿出来，我可以不进去，真的不能让她进去吗？&#8221;</span></p> <p style="line-height: 150%; margin-top: 0px; text-indent: 24px; margin-bottom: 0px"><span style="font-family: 仿宋_GB2312; color: #333333">&#8220;是的，这里将要举行一场慈善晚宴，应邀参加的都是很重要的人士，他们将为非洲的孩子慷慨解囊。很高兴你们带着爱心来到这里，但是，我想这场合不适合你们进去。&#8221;安东尼解释说。</span></p> <p style="line-height: 150%; margin-top: 0px; text-indent: 24px; margin-bottom: 0px"><span style="font-family: 仿宋_GB2312; color: #333333">&#8220;叔叔，慈善的不是钱，是心，对吗？&#8221;一直没有说话的小女孩问安东尼，她的话让安东尼愣住了。&#8220;我知道收到邀请的人有很多钱，他们会拿出很多钱，我没有那么多，但这是我所有的钱啊，如果我真的不能进去，请帮我把这个带进去吧！&#8221;小女孩露西说完，将手中的储钱罐递给安东尼。</span></p> <p style="line-height: 150%; margin-top: 0px; text-indent: 24px; margin-bottom: 0px"><span style="font-family: 仿宋_GB2312; color: #333333">安东尼不知道是接还是不接，正在他不知所措的时候，突然有人说：&#8220;不用了，孩子，你说得对，慈善的不是钱，是心，你可以进去，所有有爱心的人都可以进去。&#8221;说话的是一位老头，他面带微笑，站在小露西身旁。他躬身和小露西交谈了几句，然后直身起来，拿出一份请柬递给安东尼：&#8220;我可以带她进去吗？&#8221;</span></p> <p style="line-height: 150%; margin-top: 0px; text-indent: 24px; margin-bottom: 0px"><span style="font-family: 仿宋_GB2312; color: #333333">安东尼接过请柬，打开一看，忙向老头敬了个礼：&#8220;当然可以了，沃伦&#183;巴菲特先生。&#8221;</span></p> <p style="line-height: 150%; margin-top: 0px; text-indent: 24px; margin-bottom: 0px"><span style="font-family: 仿宋_GB2312; color: #333333">当天慈善晚宴的主角不是倡议者的安南，不是捐出300万美元的巴菲特，也不是捐出800万美元的比尔&#183;盖茨，而是仅仅捐出30美元零25美分的小露西，她赢得了最多最热烈的掌声。而晚宴的主题标语也变成了这样一句话&#8220;慈善的不是钱，是心。&#8221;第二天，美国各大媒体纷纷以这句话作为标题，报道了这次慈善晚宴。看到报道后，许多普普通通的美国人纷纷表示要为非洲那些贫穷的孩子捐赠。</span></p> </div><img src ="http://www.cppblog.com/Chipset/aggbug/153849.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2011-08-19 14:47 <a href="http://www.cppblog.com/Chipset/archive/2011/08/19/153849.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>B+树的C++实现</title><link>http://www.cppblog.com/Chipset/archive/2011/08/16/153564.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Tue, 16 Aug 2011 07:05:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2011/08/16/153564.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/153564.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2011/08/16/153564.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/153564.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/153564.html</trackback:ping><description><![CDATA[<div>关于B+树的实现和测试，我见过的最详细的C++代码在：<br />http://idlebox.net/2007/stx-btree/<br />一位德国朋友的杰作。</div><img src ="http://www.cppblog.com/Chipset/aggbug/153564.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2011-08-16 15:05 <a href="http://www.cppblog.com/Chipset/archive/2011/08/16/153564.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>架构师已死(转贴)</title><link>http://www.cppblog.com/Chipset/archive/2011/02/01/139658.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Tue, 01 Feb 2011 00:58:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2011/02/01/139658.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/139658.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2011/02/01/139658.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/139658.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/139658.html</trackback:ping><description><![CDATA[<!--[if gte mso 9]><xml>
<w:worddocument>
<w:view>Normal</w:view>
<w:zoom>0</w:zoom>
<w:punctuationkerning/>
<w:validateagainstschemas/>
<w:saveifxmlinvalid>false</w:saveifxmlinvalid>
<w:ignoremixedcontent>false</w:ignoremixedcontent>
<w:alwaysshowplaceholdertext>false</w:alwaysshowplaceholdertext>
<w:compatibility>
<w:breakwrappedtables/>
<w:snaptogridincell/>
<w:wraptextwithpunct/>
<w:useasianbreakrules/>
<w:dontgrowautofit/>
<w:usefelayout/>
</w:compatibility>
<w:browserlevel>MicrosoftInternetExplorer4</w:browserlevel>
</w:worddocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:latentstyles deflockedstate="false" latentstylecount="156">
</w:latentstyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]--><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1"/>
</o:shapelayout></xml><![endif]--><!--[if gte mso 9]><xml>
<w:worddocument>
<w:view>Normal</w:view>
<w:zoom>0</w:zoom>
<w:punctuationkerning/>
<w:validateagainstschemas/>
<w:saveifxmlinvalid>false</w:saveifxmlinvalid>
<w:ignoremixedcontent>false</w:ignoremixedcontent>
<w:alwaysshowplaceholdertext>false</w:alwaysshowplaceholdertext>
<w:compatibility>
<w:breakwrappedtables/>
<w:snaptogridincell/>
<w:wraptextwithpunct/>
<w:useasianbreakrules/>
<w:dontgrowautofit/>
<w:usefelayout/>
</w:compatibility>
<w:browserlevel>MicrosoftInternetExplorer4</w:browserlevel>
</w:worddocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:latentstyles deflockedstate="false" latentstylecount="156">
</w:latentstyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]--><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1"/>
</o:shapelayout></xml><![endif]-->
<p class="content">2006<span style="font-family: simsun;" lang="ZH-CN">年的职场出奇的冷清，相比前几年，简历的数量和质量都大为不如，很难得找到三年工作经验以上的人，有一个</span><span lang="ZH-CN"> </span><span style="font-family: simsun;" lang="ZH-CN">不是特别笨，就是特别怪。就是么，干得好谁没事换工作啊！</span>Simon<span style="font-family: simsun;" lang="ZH-CN">是一家外企软件公司的总经理，最近给这个问题愁坏了。项目一个接一个的接下来，人手越</span><span lang="ZH-CN"> </span><span style="font-family: simsun;" lang="ZH-CN">来越紧张。虽然</span>Simon<span style="font-family: simsun;" lang="ZH-CN">是个极限编程的粉丝，但也不得不批准了一份又一份的加班申请。</span>HR<span style="font-family: simsun;" lang="ZH-CN">经理把这个问题归结到房价上，他的妙论是</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">怕失业了还不上房</span><span lang="ZH-CN"> </span><span style="font-family: simsun;" lang="ZH-CN">款，不敢跳槽</span>&#8221;<span style="font-family: simsun;" lang="ZH-CN">。</span></p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">这天，</span>K<span style="font-family: simsun;" lang="ZH-CN">项目组长</span>Allen<span style="font-family: simsun;" lang="ZH-CN">终于忍不住了，带了一个只有一年工作经验的小伙子要</span>Simon<span style="font-family: simsun;" lang="ZH-CN">面试，</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">很聪明！经验少了点。</span>&#8221;</p>
<p class="content">Simon<span style="font-family: simsun;" lang="ZH-CN">皱了皱眉毛，说：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">你不知道这个职位最低要求是三年工作经验吗？</span>&#8221;</p>
<p class="content">Allen<span style="font-family: simsun;" lang="ZH-CN">说：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">这已经是三个月里通过技术考试中最好的一个了，老大，试试吧。</span>&#8221;Allen<span style="font-family: simsun;" lang="ZH-CN">是</span>Simon<span style="font-family: simsun;" lang="ZH-CN">多年的哥们，比较随便。</span></p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">抵到面子上来，</span>Simon<span style="font-family: simsun;" lang="ZH-CN">只好让</span>Allen<span style="font-family: simsun;" lang="ZH-CN">把小伙子带进来。</span></p>
<p class="content">Simon<span style="font-family: simsun;" lang="ZH-CN">的面试通常是三步曲：</span></p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">问题一：你能说说毕业后的主要工作经历吗？</span></p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">问题二：再说说你在公司的地位？</span></p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">问题三：你的发展目标是什么？等回答后，比如说架构师，他就跟着问：想象一下你当架构师的一天，说给我听听？</span></p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">小伙子回答第一问题很快很清楚，一年工作当然没什么东西。</span>Simon<span style="font-family: simsun;" lang="ZH-CN">觉得小伙子挺聪明。所以在小伙子回答了第二个问题后，问了一个发散性的问题：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">你刚才说你在公司里处于中等水平，那比你差的人为什么会比你差呢？</span>&#8221;</p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">这个问题是个陷阱。</span></p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">小伙子冒冒失失回答说：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">我觉得他们每天工作是为工作而工作，工作没有责任感。</span>&#8221;</p>
<p class="content">Simon<span style="font-family: simsun;" lang="ZH-CN">点点头说：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">是吗？那真是糟糕的员工。那你刚好比糟糕的员工好一点了？</span>&#8221;</p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">小伙子的脸一下子红了，</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">我不是这个意思</span>&#8230;&#8230;&#8221;</p>
<p class="content">&#8220;<span style="font-family: simsun;" lang="ZH-CN">好了，那你说说比你好的人为什么比你强？</span>&#8221;</p>
<p class="content">&#8220;<span style="font-family: simsun;" lang="ZH-CN">我觉得他非常努力，工作很多年了还在学习各种构架，水平很高。</span>&#8221;<span style="font-family: simsun;" lang="ZH-CN">于是</span>Simon<span style="font-family: simsun;" lang="ZH-CN">就问那最后一个问题。果然，小伙子回答的是要成为架构师。大概</span>70<span style="font-family: simsun;" lang="ZH-CN">％的人想成为架构师。但是架构师是什么呢？</span></p>
<p class="content">Simon<span style="font-family: simsun;" lang="ZH-CN">问道：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">那你为什么要成为架构师呢？</span>&#8221;</p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">小伙子一愣，大概还没有人这么置疑过他。</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">年纪大了，不能老写程序吧。</span>&#8221;<span style="font-family: simsun;" lang="ZH-CN">这个回答，让</span>Simon<span style="font-family: simsun;" lang="ZH-CN">想起关于他对什么是老的定义：当你希望做年轻人做的事情时，你就还年轻；如果你希望做老年人做的事情，你就老了。这和你出生了多长时间是没有关系的。</span></p>
<p class="content">Simon<span style="font-family: simsun;" lang="ZH-CN">接着问：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">好吧，那你说说你成为架构师以后，每天都会做什么？</span>&#8221;</p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">小伙子说：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">我还没想过，不过，我想应该主要是需求分析，设计构架吧</span>&#8230;&#8230;&#8221;<span style="font-family: simsun;" lang="ZH-CN">这大概是现在年轻人的通病，年轻人很容易追逐一些自己也不清楚的目标。</span></p>
<p class="content">Simon<span style="font-family: simsun;" lang="ZH-CN">问：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">那设计构架具体都做些什么呢？</span>&#8221;</p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">小伙子这次的回答是：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">比如，选择程序框架，决定用</span>Spring<span style="font-family: simsun;" lang="ZH-CN">或</span>Struts<span style="font-family: simsun;" lang="ZH-CN">等等。</span>&#8221;</p>
<p class="content">&#8220;<span style="font-family: simsun;" lang="ZH-CN">哦，那我问你，你怎么说服别人是用</span>Spring<span style="font-family: simsun;" lang="ZH-CN">还是</span>Struts<span style="font-family: simsun;" lang="ZH-CN">呢？</span>&#8221;</p>
<p class="content">&#8220;<span style="font-family: simsun;" lang="ZH-CN">如果我有经验，我会知道哪个更好</span>&#8230;&#8230;&#8221;</p>
<p class="content">&#8220;<span style="font-family: simsun;" lang="ZH-CN">是吗，但关于</span>Spring<span style="font-family: simsun;" lang="ZH-CN">或</span>Struts<span style="font-family: simsun;" lang="ZH-CN">的知识任谁都可以很容易得到。如果别人不同意你的建议，你怎么说服他？如果同意你的建议，那你不过是作出了和别人一样的认识，别人又凭什么认可你呢？</span>&#8221;</p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">小伙子没想过架构师日子里还有一个说服人的工作，说：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">我是架构师，我应该有权力做决定吧？</span>&#8221;</p>
<p class="content">Simon<span style="font-family: simsun;" lang="ZH-CN">想起权力的三种层次，第一层，任命；第二层，专业；第三层，品德。</span></p>
<p class="content">Simon<span style="font-family: simsun;" lang="ZH-CN">问：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">如果在一个成熟的软件企业里没有你所想象的架构师呢？或者说，架构师这种职业已经死亡或消失了呢？你会怎么定位你的职业？</span>&#8221;</p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">小伙子显得很震惊。</span></p>
<p class="content">Simon<span style="font-family: simsun;" lang="ZH-CN">画了一个系统构架，然后又给小伙子看了一段代码。</span></p>
<p class="content">&#8220;<span style="font-family: simsun;" lang="ZH-CN">那一个更难懂？</span>&#8221;Simon<span style="font-family: simsun;" lang="ZH-CN">问。</span></p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">小伙子指着代码说：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">代码难懂。</span>&#8221;</p>
<p class="content">Simon<span style="font-family: simsun;" lang="ZH-CN">的解释是：</span>&#8220;<span style="font-family: simsun;" lang="ZH-CN">这就是为什么实际上所谓的架构师不存在的原因。一个更简单的东西怎么会更有价值呢？每个人都能够画出这种构架图，但不是每个人都能写出好的代码。</span>&#8221;</p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">送走了小伙子，</span>Simon<span style="font-family: simsun;" lang="ZH-CN">有点难受。他有点喜欢这个小伙子，但是，这又是一个被愚蠢的教育和误人子弟的技术杂志污染的家伙。</span>Simon<span style="font-family: simsun;" lang="ZH-CN">在自己的笔记本中加了一句话：中国程序员最愚蠢的认识之三：我想当架构师。前面两个赫然是：</span></p>
<p class="content">35<span style="font-family: simsun;" lang="ZH-CN">岁后写不动程序了；</span></p>
<p class="content"><span style="font-family: simsun;" lang="ZH-CN">我只要做</span>Java<span style="font-family: simsun;" lang="ZH-CN">（</span>C<span style="font-family: simsun;" lang="ZH-CN">＋＋）；</span></p>
<p class="MsoNormal">&nbsp;</p><img src ="http://www.cppblog.com/Chipset/aggbug/139658.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2011-02-01 08:58 <a href="http://www.cppblog.com/Chipset/archive/2011/02/01/139658.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C++/C#/F#/Java/JS/Lua/Python/Ruby渲染速度比试</title><link>http://www.cppblog.com/Chipset/archive/2010/12/02/135260.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Thu, 02 Dec 2010 05:23:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2010/12/02/135260.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/135260.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2010/12/02/135260.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/135260.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/135260.html</trackback:ping><description><![CDATA[之前常听说C#和Java与C++的速度接近，更有甚者说很多情况下他们都比C++快，而且举出一大堆的范例(多是些IO操作，测量误差超级大，因此很难令人信服)，于是听到很多人出来圆场，说对于语言内建类型(整形、浮点型等)，编译成二进制应该相差不大，这似乎有些道理，但我仍然有些怀疑。<br><br>还曾经听不少人鼓吹过脚本，说脚本程序比C++程序慢不了多少，有人甚至给10%，对此我不加评论了，看看这里的测试结果就一目了然。<br><br>下面有个浮点密集型的计算程序，没有使用blitz++和MTL，很符合一般性应用，如果用上他们那就不好说怎么样，因为主要是和Fortran比科学计算速度时才用。已经有人编码测试了。<br>只讲速度，如果再比内存，其他几种语言就没有必要比下去了。<br><br>
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;"></span></div>
<br>不同语言版本的代码到原作者提供的地址去下载：http://files.cnblogs.com/miloyip/smallpt20100623.zip<br>下面是测试用的系统配置：<br><!--[if gte mso 9]><xml>
<w:worddocument>
<w:view>Normal</w:view>
<w:zoom>0</w:zoom>
<w:punctuationkerning/>
<w:validateagainstschemas/>
<w:saveifxmlinvalid>false</w:saveifxmlinvalid>
<w:ignoremixedcontent>false</w:ignoremixedcontent>
<w:alwaysshowplaceholdertext>false</w:alwaysshowplaceholdertext>
<w:compatibility>
<w:breakwrappedtables/>
<w:snaptogridincell/>
<w:wraptextwithpunct/>
<w:useasianbreakrules/>
<w:dontgrowautofit/>
<w:usefelayout/>
</w:compatibility>
<w:browserlevel>MicrosoftInternetExplorer4</w:browserlevel>
</w:worddocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:latentstyles deflockedstate="false" latentstylecount="156">
</w:latentstyles>
</xml><![endif]--><!--[if !mso]><object
classid="clsid:38481807-ca0e-42d2-bf39-b33af135cc4d" id="ieooui"></object>
<style>
st1\:*{behavior:url(#ieooui) }
</style>
<![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]-->
<h2><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">测试配置</span><span style="font-size: 10pt;"></span></h2>
<ul type="disc">
    <li class="MsoNormal"><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">硬件</span><span style="font-size: 10pt;">: Intel Core i7 920@2.67Ghz(4 core, HyperThread), 12GB RAM</span></li>
    <li class="MsoNormal"><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">操作系统</span><span style="font-size: 10pt;">: Microsoft Windows 7 64-bit</span></li>
</ul>
<table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">测试名称</span><span style="font-size: 10pt;"> </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">编译器</span><span style="font-size: 10pt;">/</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">解译器</span><span style="font-size: 10pt;"> </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">编译</span><span style="font-size: 10pt;">/</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">运行选项</span><span style="font-size: 10pt;"> </span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">VC++ </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Visual C++ 2008 (32-bit) </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">/Ox /Ob2 /Oi /Ot /GL /FD
            /MD /GS- /Gy /arch:SSE /fp:fast </span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">VC++_OpenMP </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Visual C++ 2008 (32-bit) </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">/Ox /Ob2 /Oi /Ot /GL /FD
            /MD /GS- /Gy /arch:SSE /fp:fast /openmp </span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">IC++ </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Intel C++ Compiler (32-bit)
            </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">/Ox /Og /Ob2 /Oi /Ot /Qipo
            /GA /MD /GS- /Gy /arch:SSE2 /fp:fast /Zi /QxHost </span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">IC++_OpenMP </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Intel C++ Compiler (32-bit)
            </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">/Ox /Og /Ob2 /Oi /Ot /Qipo
            /GA /MD /GS- /Gy /arch:SSE2 /fp:fast /Zi /QxHost /Qopenmp </span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">GCC </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">GCC 4.3.4
            in Cygwin (32-bit) </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">-O3 -march=native
            -ffast-math </span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">GCC_OpenMP </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">GCC 4.3.4
            in Cygwin (32-bit) </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">-O3 -march=native
            -ffast-math -fopenmp </span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">C++/CLI </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Visual C++ 2008 (32-bit),
            .Net Framework 3.5 </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">/Ox /Ob2 /Oi /Ot /GL /FD
            /MD /GS- /fp:fast /Zi /clr /TP </span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">C++/CLI_OpenMP </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Visual C++ 2008 (32-bit),
            .Net Framework 3.5 </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">/Ox /Ob2 /Oi /Ot /GL /FD
            /MD /GS- /fp:fast /Zi /clr /TP /openmp </span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">C# </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Visual C# 2008 (32-bit),
            .Net Framework 3.5 </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">*C#_outref </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Visual C# 2008 (32-bit),
            .Net Framework 3.5 </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">F# </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p><span style="font-size: 10pt;">F# 2.0 (32-bit), .Net Framework 3.5 </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Java </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Java SE 1.6.0_17
            </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal" style="text-align: justify;"><span style="font-size: 10pt;">-server </span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">JsChrome </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Chrome 5.0.375.86 </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">JsFirefox </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Firefox 3.6 </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">LuaJIT </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">LuaJIT 2.0.0-beta4
            (32-bit) </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Lua </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">LuaJIT (32-bit) </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">-joff </span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Python </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Python 3.1.2
            (32-bit) </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">*IronPython </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">IronPython 2.6 for .Net 4 </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">*Jython </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Jython 2.5.1
            </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span></p>
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2.25pt;" width="20%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Ruby </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">Ruby 1.9.1p378 </span></p>
            </td>
            <td style="width: 40%; padding: 2.25pt;" width="40%">
            <p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span></p>
            </td>
        </tr>
    </tbody>
</table>
<p><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">渲染的解像度为</span><span style="font-size: 10pt;">256x256</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">，每象素作</span><span style="font-size: 10pt;">100</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">次采样。</span><span style="font-size: 10pt;"></span></p>
<!--[if gte mso 9]><xml>
<w:worddocument>
<w:view>Normal</w:view>
<w:zoom>0</w:zoom>
<w:punctuationkerning/>
<w:validateagainstschemas/>
<w:saveifxmlinvalid>false</w:saveifxmlinvalid>
<w:ignoremixedcontent>false</w:ignoremixedcontent>
<w:alwaysshowplaceholdertext>false</w:alwaysshowplaceholdertext>
<w:compatibility>
<w:breakwrappedtables/>
<w:snaptogridincell/>
<w:wraptextwithpunct/>
<w:useasianbreakrules/>
<w:dontgrowautofit/>
<w:usefelayout/>
</w:compatibility>
<w:browserlevel>MicrosoftInternetExplorer4</w:browserlevel>
</w:worddocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:latentstyles deflockedstate="false" latentstylecount="156">
</w:latentstyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]-->
<h2><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">结果及分析</span><span style="font-size: 10pt;"></span></h2>
<p><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">下表中预设的相对时间以最快的单线程测试</span><span style="font-size: 10pt;">(IC++)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">作基准，用鼠标按列可改变基准。由于</span><span style="font-size: 10pt;">Ruby</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">运行时间太长，只每象素作</span><span style="font-size: 10pt;">4</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">次采样，把时间乘上</span><span style="font-size: 10pt;">25</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">。另</span><span style="font-size: 10pt;" lang="ZH-CN"> </span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">外，因为各测试的渲染时间相差很远，所以用了两个棒形图去显示数据，分别显示时间少于</span><span style="font-size: 10pt;">4000</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">秒和少于</span><span style="font-size: 10pt;">60</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">秒的测试</span><span style="font-size: 10pt;">(Ruby</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">是</span><span style="font-size: 10pt;">4000</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">秒以外，不予显</span><span style="font-size: 10pt;" lang="ZH-CN"> </span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">示</span><span style="font-size: 10pt;">)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">。</span><span style="font-size: 10pt;"> </span></p>
<table class="MsoNormalTable" style="width: 300pt;" border="0" cellpadding="0" cellspacing="0" width="400">
    <tbody>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">Test</span><span class="google-visualization-table-sortind"><span style="font-size: 10pt; font-family: &quot;ms mincho&quot;;" lang="ZH-CN">&#8195;</span></span><span style="font-size: 10pt;"></span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">Time(sec)</span><span class="google-visualization-table-sortind"><span style="font-size: 10pt; font-family: &quot;ms mincho&quot;;" lang="ZH-CN">&#8195;</span></span><span style="font-size: 10pt;"></span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">Relative time</span><span class="google-visualization-table-sortind"><span style="font-size: 10pt; font-family: &quot;ms mincho&quot;;" lang="ZH-CN">&#8195;</span></span><span style="font-size: 10pt;"></span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">IC++_OpenMP</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">2.861</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">0.19x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">VC++_OpenMP</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">3.140</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">0.21x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">GCC_OpenMP</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">3.359</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">0.23x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">C++/CLI_OpenMP</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">5.147</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">0.35x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">IC++</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">14.761</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">1.00x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">VC++</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">17.632</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">1.19x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">GCC</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">19.500</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">1.32x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">C++/CLI</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">27.634</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">1.87x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">Java</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">30.527</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">2.07x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">C#_outref</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">44.220</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">3.00x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">F#</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">47.172</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">3.20x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">C#</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">48.194</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">3.26x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">JsChrome</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">237.880</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">16.12x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">LuaJIT</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">829.777</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">56.21x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">Lua</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">1,227.656</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">83.17x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">IronPython</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">2,921.573</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">197.93x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">JsFirefox</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">3,588.778</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">243.13x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">Python</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">3,920.556</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">265.60x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">Jython</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">6,211.550</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">420.81x</span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">Ruby</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">77,859.653</span></p>
            </td>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal"><span style="font-size: 10pt;">5,274.69x</span></p>
            </td>
        </tr>
    </tbody>
</table>
<h3><span style="font-size: 10pt;">C++/.Net/Java</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">组别</span><span style="font-size: 10pt;"></span></h3>
<p><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">静态语言和动态语言在此测试下的性能不在同一数量级。先比较静态语言。</span><span style="font-size: 10pt;"></span></p>
<p><span style="font-size: 10pt;">C++</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">和</span><span style="font-size: 10pt;">.Net</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的测试结果和上一篇博文相若，而</span><span style="font-size: 10pt;">C#</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">和</span><span style="font-size: 10pt;">F#</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">无显著区别。但是，</span><span style="font-size: 10pt;">C++/CLI</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">虽然同样产生</span><span style="font-size: 10pt;">IL</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">，于括管的</span><span style="font-size: 10pt;">.Net</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">平台上执行，其渲染时间</span><span style="font-size: 10pt;" lang="ZH-CN">
</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">却只是</span><span style="font-size: 10pt;">C#/F#</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的</span><span style="font-size: 10pt;">55%</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">左右。为什么呢？使用</span><span style="font-size: 10pt;">ildasm</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">去反汇编</span><span style="font-size: 10pt;">C++/CLI</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">和</span><span style="font-size: 10pt;">C#</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的可执行文件后，可以发现，程序的热点函数</span><span style="font-size: 10pt;">
Sphere.Intersect()</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">在两个版本中，</span><span style="font-size: 10pt;">C++/CLI</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">版本的代码大小</span><span style="font-size: 10pt;">(code size)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">为</span><span style="font-size: 10pt;">201</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">字节，</span><span style="font-size: 10pt;"> C#</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">则为</span><span style="font-size: 10pt;">125</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">字节！</span><span style="font-size: 10pt;"> C++/CLI</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">版本在编译时，已把函数内所有</span><span style="font-size: 10pt;">Vec</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">类的方法调用全部内联，而</span><span style="font-size: 10pt;">C#</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">版本则使用</span><span style="font-size: 10pt;">callvirt</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">调用</span><span style="font-size: 10pt;">Vec</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的方法。估计</span><span style="font-size: 10pt;">JIT</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">没有把这函数进</span><span style="font-size: 10pt;" lang="ZH-CN"> </span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">行内联，做成这个性能差异。另外，</span><span style="font-size: 10pt;">C++/CLI</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">版本使用了值类型，并使用指针</span><span style="font-size: 10pt;">(</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">代码中为引用</span><span style="font-size: 10pt;">)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">托管代码</span><span style="font-size: 10pt;">(C++/CLI)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的渲染时间，仅为原生非括管代码</span><span style="font-size: 10pt;">(IC++)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的</span><span style="font-size: 10pt;">1.91</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">倍，个人觉得</span><span style="font-size: 10pt;">.Net</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的</span><span style="font-size: 10pt;">JIT</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">已经非常不错。</span><span style="font-size: 10pt;"> </span></p>
<p><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">另一方面，</span><span style="font-size: 10pt;">Java</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的性能表现非常突出，只比</span><span style="font-size: 10pt;">C++/CLI</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">稍慢一点，</span><span style="font-size: 10pt;">Java</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">版本的渲染时间为</span><span style="font-size: 10pt;">C#/F#</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的</span><span style="font-size: 10pt;">65%</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">左右。以前一直认为，</span><span style="font-size: 10pt;">C#</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">不少设计会使其性能高于</span><span style="font-size: 10pt;">Java</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">，例如</span><span style="font-size: 10pt;">C#</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的方法预设为非虚，</span><span style="font-size: 10pt;">Java</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">则预设为虚；又例如</span><span style="font-size: 10pt;">C#</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">支持</span><span style="font-size: 10pt;">struct</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">作值类型</span><span style="font-size: 10pt;">(value type)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">，</span><span style="font-size: 10pt;">Java</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">则只有</span><span style="font-size: 10pt;">class</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">引用类型</span><span style="font-size: 10pt;">(reference type)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">，后者必须使用</span><span style="font-size: 10pt;">GC</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">。但是，这个测试显示，</span><span style="font-size: 10pt;">Java VM</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">应该在</span><span style="font-size: 10pt;">JIT</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">中做了大量优化，估计也应用了内联，才能使其性能逼近</span><span style="font-size: 10pt;">C++/CLI</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">。</span><span style="font-size: 10pt;"> </span></p>
<p><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">纯</span><span style="font-size: 10pt;">C++</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">方面，</span><span style="font-size: 10pt;">Intel C++</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">编译器最快，</span><span style="font-size: 10pt;">Visual C++</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">慢一点点</span><span style="font-size: 10pt;">(1.19x)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">，</span><span style="font-size: 10pt;">GCC</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">再慢一点点</span><span style="font-size: 10pt;">(1.32x)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">。这结果符合本人预期。</span><span style="font-size: 10pt;"> Intel C++</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的</span><span style="font-size: 10pt;">OpenMP</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">版本和单线程比较，达</span><span style="font-size: 10pt;">5.16</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">加速比</span><span style="font-size: 10pt;">(speedup)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">，对于</span><span style="font-size: 10pt;">4</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">核</span><span style="font-size: 10pt;">Hyper Threading</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">来说算是不错的结果。读者若有兴趣，也可以自行测试</span><span style="font-size: 10pt;">C# 4.0</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的并行新特性。</span><span style="font-size: 10pt;"> </span></p>
<h3><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">动态语言组别</span><span style="font-size: 10pt;"></span></h3>
<p><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">首先，要说一句，</span><span style="font-size: 10pt;">Google</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">太强了，难以想像</span><span style="font-size: 10pt;">JsChome</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的渲染时间仅是</span><span style="font-size: 10pt;">IC++</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的</span><span style="font-size: 10pt;">16.12</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">倍，</span><span style="font-size: 10pt;">C#</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的</span><span style="font-size: 10pt;">4.94</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">倍。</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN"></span><span style="font-size: 10pt;"> </span></p>
<p><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">以下比较各动态语言的相对时间，以</span><span style="font-size: 10pt;">JsChrome</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">为基准。</span><span style="font-size: 10pt;"> Chrome</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的</span><span style="font-size: 10pt;">V8 JavaScript</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">引擎</span><span style="font-size: 10pt;">(1.00x)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">大幅抛离</span><span style="font-size: 10pt;">Firefox</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的</span><span style="font-size: 10pt;">SpiderMonkey</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">引擎</span><span style="font-size: 10pt;">(15.09x)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">。而</span><span style="font-size: 10pt;">LuaJIT(3.49x)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">和</span><span style="font-size: 10pt;">Lua(5.16x)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">则排第二和第三名。</span><span style="font-size: 10pt;"> Lua</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的</span><span style="font-size: 10pt;">JIT</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">版本是没有</span><span style="font-size: 10pt;">JIT</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的</span><span style="font-size: 10pt;">68%</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">，并没有想像中的快，但是也比</span><span style="font-size: 10pt;">Python(16.48x)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">快得多。曾听说过</span><span style="font-size: 10pt;">Ruby</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">有效能问题，没想到问题竟然如此严重</span><span style="font-size: 10pt;">(327.31x)</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">，其渲染时间差不多是</span><span style="font-size: 10pt;">Python</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">的</span><span style="font-size: 10pt;">20</span><span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN">倍.</span><span style="font-size: 10pt;"> </span></p>
<span style="font-size: 10pt; font-family: simsun;" lang="ZH-CN"></span><span style="font-size: 10pt;"></span>
<br> <img src ="http://www.cppblog.com/Chipset/aggbug/135260.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2010-12-02 13:23 <a href="http://www.cppblog.com/Chipset/archive/2010/12/02/135260.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C#, C++, Java性能对比</title><link>http://www.cppblog.com/Chipset/archive/2009/03/01/75266.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Sun, 01 Mar 2009 14:22:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2009/03/01/75266.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/75266.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2009/03/01/75266.html#Feedback</comments><slash:comments>8</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/75266.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/75266.html</trackback:ping><description><![CDATA[<br>摘选自Onur&nbsp;Gumus的博客。<br><a  href="http://reverseblade.blogspot.com/2009/02/c-versus-c-versus-java-performance.html" target="_blank">http://reverseblade.blogspot.com/2009/02/c-versus-c-versus-java-performance.html</a><br><br>C#&nbsp;vs&nbsp;C++&nbsp;vs&nbsp;Java性能对比<br><br>C#,&nbsp;Java
和C++对比性能常常是引发争议的一个话题。那些不熟悉JIT的人常常声称JIT上运行的任何程序跟C++比速度都不行。而那些使用Java和C#的人则
常常声称性能差别甚小，几乎可以忽略不计。这里有一个测试对比结果图，来自freenode&nbsp;IRC服务器，不知道谁测试的，但是结果似乎很真实。&nbsp;<br><br>对于我来说，因为性能原因选择C++似乎理由不足。记住：工程师比服务器要昂贵的多！<br><img alt=""  src="http://www.cppblog.com/images/cppblog_com/chipset/benchmarksJan2009Final.gif"><br><br>部分其他人的评论：<br><br>单线程测试的，多线程如何？内存耗费多少？测试程序数据使用的语言内建类型(比如int)还是自定义类型，如果语言本身内建的类型那编译成二进制测试时间消耗差别不会多大是正常的。<br>PHP没有针对Windows系统优化，因此速度肯定上不去。<br>在Windows上测试Java是否运行在虚拟机上？默认情况可并非如此(跟Linux可不同)！再者，测试结果耗费时间太短误差相对可能很大，很难说明实际情形。<br><br>更多评论...<img src ="http://www.cppblog.com/Chipset/aggbug/75266.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2009-03-01 22:22 <a href="http://www.cppblog.com/Chipset/archive/2009/03/01/75266.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>测试CPU品牌和当前工作频率</title><link>http://www.cppblog.com/Chipset/archive/2009/02/20/74402.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Fri, 20 Feb 2009 06:58:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2009/02/20/74402.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/74402.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2009/02/20/74402.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/74402.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/74402.html</trackback:ping><description><![CDATA[<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">这里有一段非常简单的代码，取自网络，我稍加修改，贴在这里。用来检查CPU的生产商和品牌，以及当前工作频率，如果是台式机CPU，频率应该恒定，但是移动版本的CPU，频率不停地在变。以下代码用Visual&nbsp;C</span><span style="color: #000000;">++</span><span style="color: #000000;">编译，因为内嵌一点汇编，造成移植性变差(例如：GCC汇编跟AT</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">T汇编语法类似，但是MS汇编跟Intel汇编语法类似)，以下代码如果希望在MinGW(GCC)下编译，需要修改那点内嵌的汇编。<br><br>#include&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">stdafx.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>#ifndef&nbsp;CPUID_HPP_<br></span><span style="color: #0000ff;">#define</span><span style="color: #000000;">&nbsp;CPUID_HPP_</span><span style="color: #000000;"><br><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">cstring</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">iostream</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">windows.h</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br><br>typedef&nbsp;unsigned&nbsp;</span><span style="color: #0000ff;">long</span><span style="color: #000000;">&nbsp;DWORD;<br>typedef&nbsp;__int64&nbsp;LONGLONG;<br><br></span><span style="color: #0000ff;">class</span><span style="color: #000000;">&nbsp;CPUID<br>{<br></span><span style="color: #0000ff;">public</span><span style="color: #000000;">:<br>&nbsp;&nbsp;CPUID()&nbsp;:&nbsp;m_eax(</span><span style="color: #000000;">0</span><span style="color: #000000;">),&nbsp;m_ebx(</span><span style="color: #000000;">0</span><span style="color: #000000;">),&nbsp;m_ecx(</span><span style="color: #000000;">0</span><span style="color: #000000;">),&nbsp;m_edx(</span><span style="color: #000000;">0</span><span style="color: #000000;">){}<br>&nbsp;&nbsp;std::</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;vendor();&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">哪个厂商出的？Intel,&nbsp;AMD,&nbsp;VIA&nbsp;?</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;&nbsp;std::</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;name();&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">这是CPU的整体描述</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;&nbsp;LONGLONG&nbsp;frequency(DWORD&nbsp;stime&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">1000</span><span style="color: #000000;">);</span><span style="color: #008000;">//</span><span style="color: #008000;">CPU的当前工作频率</span><span style="color: #008000;"><br></span><span style="color: #000000;"><br></span><span style="color: #0000ff;">private</span><span style="color: #000000;">:<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;&nbsp;Executecpuid(DWORD&nbsp;veax);<br>&nbsp;&nbsp;LONGLONG&nbsp;cycles()&nbsp;</span><span style="color: #0000ff;">const</span><span style="color: #000000;"><br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;DWORD&nbsp;h,&nbsp;l;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">不能直接读取，用变量过渡一下</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;__asm<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rdtsc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">把当前CPU周期读入寄存器</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mov&nbsp;l,&nbsp;eax<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mov&nbsp;h,&nbsp;edx<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;LONGLONG&nbsp;high&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;h,&nbsp;low&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;l;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;high&nbsp;</span><span style="color: #000000;">&lt;&lt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">32</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">|</span><span style="color: #000000;">&nbsp;low;<br>&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;DWORD&nbsp;&nbsp;m_eax;<br>&nbsp;&nbsp;DWORD&nbsp;&nbsp;m_ebx;<br>&nbsp;&nbsp;DWORD&nbsp;&nbsp;m_ecx;<br>&nbsp;&nbsp;DWORD&nbsp;&nbsp;m_edx;<br>};<br><br></span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;CPUID::Executecpuid(DWORD&nbsp;veax)<br>{<br>&nbsp;&nbsp;DWORD&nbsp;deax;<br>&nbsp;&nbsp;DWORD&nbsp;debx;<br>&nbsp;&nbsp;DWORD&nbsp;decx;<br>&nbsp;&nbsp;DWORD&nbsp;dedx;<br><br>&nbsp;&nbsp;__asm<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;mov&nbsp;eax,&nbsp;veax<br>&nbsp;&nbsp;&nbsp;&nbsp;cpuid<br>&nbsp;&nbsp;&nbsp;&nbsp;mov&nbsp;deax,&nbsp;eax<br>&nbsp;&nbsp;&nbsp;&nbsp;mov&nbsp;debx,&nbsp;ebx<br>&nbsp;&nbsp;&nbsp;&nbsp;mov&nbsp;decx,&nbsp;ecx<br>&nbsp;&nbsp;&nbsp;&nbsp;mov&nbsp;dedx,&nbsp;edx<br>&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;m_eax&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;deax;<br>&nbsp;&nbsp;m_ebx&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;debx;<br>&nbsp;&nbsp;m_ecx&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;decx;<br>&nbsp;&nbsp;m_edx&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;dedx;<br>}<br><br>std::</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;CPUID::vendor()<br>{<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;DWORD&nbsp;S&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(DWORD);<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">&nbsp;cVID[S</span><span style="color: #000000;">*</span><span style="color: #000000;">3</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">];<br>&nbsp;&nbsp;std::memset(cVID,&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">,&nbsp;</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(cVID));<br>&nbsp;&nbsp;Executecpuid(</span><span style="color: #000000;">0</span><span style="color: #000000;">);<br>&nbsp;&nbsp;std::memcpy(cVID</span><span style="color: #000000;">+</span><span style="color: #000000;">S</span><span style="color: #000000;">*</span><span style="color: #000000;">0</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">m_ebx,&nbsp;S);<br>&nbsp;&nbsp;std::memcpy(cVID</span><span style="color: #000000;">+</span><span style="color: #000000;">S</span><span style="color: #000000;">*</span><span style="color: #000000;">1</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">m_edx,&nbsp;S);<br>&nbsp;&nbsp;std::memcpy(cVID</span><span style="color: #000000;">+</span><span style="color: #000000;">S</span><span style="color: #000000;">*</span><span style="color: #000000;">2</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">m_ecx,&nbsp;S);<br><br>&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;std::</span><span style="color: #0000ff;">string</span><span style="color: #000000;">(cVID);<br>}<br><br>std::</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;CPUID::name()<br>{<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;DWORD&nbsp;vendorID&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0x80000002</span><span style="color: #000000;">;<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;DWORD&nbsp;S&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(DWORD);<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">&nbsp;cvendor[S</span><span style="color: #000000;">*</span><span style="color: #000000;">4</span><span style="color: #000000;">*</span><span style="color: #000000;">3</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">];<br>&nbsp;&nbsp;std::memset(cvendor,&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">,&nbsp;</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(cvendor));<br><br>&nbsp;&nbsp;</span><span style="color: #0000ff;">for</span><span style="color: #000000;">(DWORD&nbsp;i&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;&nbsp;i&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">3</span><span style="color: #000000;">;&nbsp;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;Executecpuid(vendorID&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;i);<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;每次执行结束后，保存四个寄存器里的ascii码到数组</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;std::memcpy(cvendor&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;i</span><span style="color: #000000;">*</span><span style="color: #000000;">S</span><span style="color: #000000;">*</span><span style="color: #000000;">4</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;S</span><span style="color: #000000;">*</span><span style="color: #000000;">0</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">m_eax,&nbsp;S);<br>&nbsp;&nbsp;&nbsp;&nbsp;std::memcpy(cvendor&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;i</span><span style="color: #000000;">*</span><span style="color: #000000;">S</span><span style="color: #000000;">*</span><span style="color: #000000;">4</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;S</span><span style="color: #000000;">*</span><span style="color: #000000;">1</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">m_ebx,&nbsp;S);<br>&nbsp;&nbsp;&nbsp;&nbsp;std::memcpy(cvendor&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;i</span><span style="color: #000000;">*</span><span style="color: #000000;">S</span><span style="color: #000000;">*</span><span style="color: #000000;">4</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;S</span><span style="color: #000000;">*</span><span style="color: #000000;">2</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">m_ecx,&nbsp;S);<br>&nbsp;&nbsp;&nbsp;&nbsp;std::memcpy(cvendor&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;i</span><span style="color: #000000;">*</span><span style="color: #000000;">S</span><span style="color: #000000;">*</span><span style="color: #000000;">4</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;S</span><span style="color: #000000;">*</span><span style="color: #000000;">3</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">m_edx,&nbsp;S);<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;std::</span><span style="color: #0000ff;">string</span><span style="color: #000000;">(cvendor);<br>}<br><br>LONGLONG&nbsp;CPUID::frequency(DWORD&nbsp;stime)<br>{<br>&nbsp;&nbsp;HANDLE&nbsp;hp&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;GetCurrentProcess();<br>&nbsp;&nbsp;HANDLE&nbsp;ht&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;GetCurrentThread();<br><br>&nbsp;&nbsp;DWORD&nbsp;pc&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;GetPriorityClass(hp);<br>&nbsp;&nbsp;DWORD&nbsp;tp&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;GetThreadPriority(ht);<br><br>&nbsp;&nbsp;BOOL&nbsp;flag1&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;FALSE,&nbsp;flag2&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;FALSE;<br><br>&nbsp;&nbsp;flag1&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;SetPriorityClass(hp,&nbsp;REALTIME_PRIORITY_CLASS);&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">优先级设置最高</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;&nbsp;flag2&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;SetThreadPriority(ht,&nbsp;THREAD_PRIORITY_HIGHEST);</span><span style="color: #008000;">//</span><span style="color: #008000;">优先级设置最高<br><br>&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">由于CPU本身时间波动较大，因此时间从系统读取，这样比较平均</span><span style="color: #008000;"><br>&nbsp; //周期除以时间就是工作频率，即单位时间内的周期<br></span><span style="color: #000000;">&nbsp;&nbsp;Sleep(stime);<br>&nbsp;&nbsp;LARGE_INTEGER&nbsp;fq,&nbsp;st,&nbsp;ed;<br>&nbsp;&nbsp;QueryPerformanceFrequency(</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">fq);<br>&nbsp;&nbsp;QueryPerformanceCounter(</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">st);<br>&nbsp;&nbsp;LONGLONG&nbsp;start&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;cycles();<br>&nbsp;&nbsp;Sleep(stime);<br>&nbsp;&nbsp;QueryPerformanceCounter(</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">ed);<br>&nbsp;&nbsp;LONGLONG&nbsp;end&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;cycles();<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">(flag1)<br>&nbsp;&nbsp;&nbsp;&nbsp;SetPriorityClass(hp,&nbsp;pc);<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">(flag2)<br>&nbsp;&nbsp;&nbsp;&nbsp;SetThreadPriority(ht,&nbsp;tp);<br><br>&nbsp;&nbsp;CloseHandle(hp);<br>&nbsp;&nbsp;CloseHandle(ht);<br><br>&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;(end&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">&nbsp;start)&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;fq.QuadPart&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">&nbsp;(ed.QuadPart&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">&nbsp;st.QuadPart);<br>}<br><br></span><span style="color: #0000ff;">#endif</span><span style="color: #000000;"><br><br><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">cstdio</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">cstdlib</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;main()<br>{<br>&nbsp;&nbsp;CPUID&nbsp;cpu;<br>&nbsp;&nbsp;std::printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">Vendor:&nbsp;%s\n</span><span style="color: #000000;">"</span><span style="color: #000000;">,&nbsp;cpu.vendor().c_str());<br>&nbsp;&nbsp;std::printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">Full&nbsp;name:&nbsp;%s\n</span><span style="color: #000000;">"</span><span style="color: #000000;">,&nbsp;cpu.name().c_str());<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;unsigned&nbsp;TIMES&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">3</span><span style="color: #000000;">;<br>&nbsp;&nbsp;std::printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">Frequency(testing&nbsp;%d&nbsp;times):&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">,&nbsp;TIMES);<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">double</span><span style="color: #000000;">&nbsp;UNIT&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">1000.0</span><span style="color: #000000;">;<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">for</span><span style="color: #000000;">(unsigned&nbsp;i&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;&nbsp;i&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">&nbsp;TIMES;&nbsp;</span><span style="color: #000000;">++</span><span style="color: #000000;">i)<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">double</span><span style="color: #000000;">&nbsp;fre&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;cpu.frequency()&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">&nbsp;UNIT;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;假设CPU主频高于1000Hz</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">(fre&nbsp;</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;UNIT)&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fre&nbsp;</span><span style="color: #000000;">/=</span><span style="color: #000000;">&nbsp;UNIT;<br>&nbsp;&nbsp;&nbsp;&nbsp;std::printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%f%s&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">,&nbsp;fre,&nbsp;(fre&nbsp;</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">10.0</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">?</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">MHz</span><span style="color: #000000;">"</span><span style="color: #000000;">&nbsp;:&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">GHz</span><span style="color: #000000;">"</span><span style="color: #000000;">));<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">\n</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>&nbsp;&nbsp;std::system(</span><span style="color: #000000;">"</span><span style="color: #000000;">PAUSE</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}</span></div>
<br> <img src ="http://www.cppblog.com/Chipset/aggbug/74402.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2009-02-20 14:58 <a href="http://www.cppblog.com/Chipset/archive/2009/02/20/74402.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Mersenne twister -- 目前为止最好的随机数算法</title><link>http://www.cppblog.com/Chipset/archive/2009/01/19/72330.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Mon, 19 Jan 2009 10:58:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2009/01/19/72330.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/72330.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2009/01/19/72330.html#Feedback</comments><slash:comments>16</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/72330.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/72330.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: v\:* {behavior:url(#default#VML);}o\:* {behavior:url(#default#VML);}w\:* {behavior:url(#default#VML);}.shape {behavior:url(#default#VML);}Normal07.8 pt02falsefalsefalse...&nbsp;&nbsp;<a href='http://www.cppblog.com/Chipset/archive/2009/01/19/72330.html'>阅读全文</a><img src ="http://www.cppblog.com/Chipset/aggbug/72330.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2009-01-19 18:58 <a href="http://www.cppblog.com/Chipset/archive/2009/01/19/72330.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>B树、B-树、B+树、B*树都是什么(转载)</title><link>http://www.cppblog.com/Chipset/archive/2009/01/05/71265.html</link><dc:creator>山寨科技</dc:creator><author>山寨科技</author><pubDate>Mon, 05 Jan 2009 15:45:00 GMT</pubDate><guid>http://www.cppblog.com/Chipset/archive/2009/01/05/71265.html</guid><wfw:comment>http://www.cppblog.com/Chipset/comments/71265.html</wfw:comment><comments>http://www.cppblog.com/Chipset/archive/2009/01/05/71265.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Chipset/comments/commentRss/71265.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Chipset/services/trackbacks/71265.html</trackback:ping><description><![CDATA[<font size="2"><span><font face="Times New Roman">
<p><font size="2"><span><font face="Times New Roman">B</font></span><span>树</span></font></p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>即二叉搜索树：</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>1.</font></span><span>所有非叶子结点至多拥有两个儿子（</span><span><font face="Times New Roman">Left</font></span><span>和</span><span><font face="Times New Roman">Right</font></span><span>）；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>2.</font></span><span>所有结点存储一个关键字；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>3.</font></span><span>非叶子结点的左指针指向小于其关键字的子树，右指针指向大于其关键字的子树；</span></font></p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>如：</span></font></p>
<p><font size="2"><span></span></font><font size="2"><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></span></font></p>
<p align="center"><img src="http://www.cppblog.com/images/cppblog_com/emptysoul/1.JPG" border="0"></p>
<p><font size="2"><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B</font></span><span>树的搜索，从根结点开始，如果查询的关键字与结点的关键字相等，那么就命中；否则，如果查询关键字比结点关键字小，就进入左儿子；如果比结点关键字大，就进入右儿子；如果左儿子或右儿子的指针为空，则报告找不到相应的关键字；</span></font></p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>如果</span><span><font face="Times New Roman">B</font></span><span>树的所有非叶子结点的左右子树的结点数目均保持差不多（平衡），那么</span><span><font face="Times New Roman">B</font></span><span>树的搜索性能逼近二分查找；但它比连续内存空间的二分查找的优点是，改变</span><span><font face="Times New Roman">B</font></span><span>树结构（插入与删除结点）不需要移动大段的内存数据，甚至通常是常数开销；</span></font><font size="2"><span><span><font face="Times New Roman">&nbsp;</font></span></span></font></p>
<p><font size="2"><span></span><span>&nbsp;&nbsp;&nbsp;但</span><span><font face="Times New Roman">B</font></span><span>树在经过多次插入与删除后，有可能导致不同的结构：</span></font></p>
<p align="center"><font size="2"><span><img src="http://www.cppblog.com/images/cppblog_com/emptysoul/31.jpg" border="0"></span></font></p>
<span>
<p align="left"><font size="2"><span><span><font face="Times New Roman"><span>&nbsp;&nbsp; 右边也是一个</span><span><font face="Times New Roman">B</font></span><span>树，但它的搜索性能已经是线性的了；同样的关键字集合有可能导致不同的树结构索引；所以，使用</span><span><font face="Times New Roman">B</font></span><span>树还要考虑尽可能让</span><span><font face="Times New Roman">B</font></span><span>树保持左图的结构，和避免右图的结构，也就是所谓的&#8220;平衡&#8221;问题；</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span></font></p>
<p align="left"><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>实际使用的</span><span><font face="Times New Roman">B</font></span><span>树都是在原</span><span><font face="Times New Roman">B</font></span><span>树的基础上加上平衡算法，即&#8220;平衡二叉树&#8221;；如何保持</span><span><font face="Times New Roman">B</font></span><span>树结点分布均匀的平衡算法是平衡二叉树的关键；平衡算法是一种在</span><span><font face="Times New Roman">B</font></span><span>树中插入和删除结点的策略；</span></font></p>
<p><span><font face="Times new roman" size="2">&nbsp;</font></span></p>
<p><span></span></p>
<p><font size="2"><span><font face="Times New Roman">B-</font></span><span>树</span></font></p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>是一种多路搜索树（并不是二叉的）：</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>1.</font></span><span>定义任意非叶子结点最多只有</span><span><font face="Times New Roman">M</font></span><span>个儿子；且</span><span><font face="Times New Roman">M&gt;2</font></span><span>；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>2.</font></span><span>根结点的儿子数为</span><span><font face="Times New Roman">[2, M]</font></span><span>；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>3.</font></span><span>除根结点以外的非叶子结点的儿子数为</span><span><font face="Times New Roman">[M/2, M]</font></span><span>；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>4.</font></span><span>每个结点存放至少</span><span><font face="Times New Roman">M/2-1</font></span><span>（取上整）和至多</span><span><font face="Times New Roman">M-1</font></span><span>个关键字；（至少</span><span><font face="Times New Roman">2</font></span><span>个关键字）</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>5.</font></span><span>非叶子结点的关键字个数</span><span><font face="Times New Roman">=</font></span><span>指向儿子的指针个数</span><span><font face="Times New Roman">-1</font></span><span>；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>6.</font></span><span>非叶子结点的关键字：</span><span><font face="Times New Roman">K[1], K[2], &#8230;, K[M-1]</font></span><span>；且</span><span><font face="Times New Roman">K[i] &lt; K[i+1]</font></span><span>；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>7.</font></span><span>非叶子结点的指针：</span><span><font face="Times New Roman">P[1], P[2], &#8230;, P[M]</font></span><span>；其中</span><span><font face="Times New Roman">P[1]</font></span><span>指向关键字小于</span><span><font face="Times New Roman">K[1]</font></span><span>的子树，</span><span><font face="Times New Roman">P[M]</font></span><span>指向关键字大于</span><span><font face="Times New Roman">K[M-1]</font></span><span>的子树，其它</span><span><font face="Times New Roman">P[i]</font></span><span>指向关键字属于</span><span><font face="Times New Roman">(K[i-1], K[i])</font></span><span>的子树；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>8.</font></span><span>所有叶子结点位于同一层；</span></font></p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>如：（</span><span><font face="Times New Roman">M=3</font></span><span>）</span></font></p>
<p align="center"><font size="2"><span><span><img src="http://www.cppblog.com/images/cppblog_com/emptysoul/b-.JPG" border="0"></span></span></font></p>
<p align="left"><span><font size="2"><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B-</font></span><span>树的搜索，从根结点开始，对结点内的关键字（有序）序列进行二分查找，如果命中则结束，否则进入查询关键字所属范围的儿子结点；重复，直到所对应的儿子指针为空，或已经是叶子结点；</span></font></span><font size="2"><span></span></font></p>
<p><font size="2"><span><font face="Times New Roman">B-</font></span><span>树的特性：</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>1.</font></span><span>关键字集合分布在整颗树中；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>2.</font></span><span>任何一个关键字出现且只出现在一个结点中；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>3.</font></span><span>搜索有可能在非叶子结点结束；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>4.</font></span><span>其搜索性能等价于在关键字全集内做一次二分查找；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>5.</font></span><span>自动层次控制；</span></font></p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>由于限制了除根结点以外的非叶子结点，至少含有</span><span><font face="Times New Roman">M/2</font></span><span>个儿子，确保了结点的至少利用率，其最底搜索性能为：</span></font></p>
<p align="center"><span><font face="Times New Roman"><font size="2"><span><img src="http://www.cppblog.com/images/cppblog_com/emptysoul/B-1.JPG" border="0"></span></font></font></span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>其中，</span><span><font face="Times New Roman">M</font></span><span>为设定的非叶子结点最多子树个数，</span><span><font face="Times New Roman">N</font></span><span>为关键字总数；</span></font></p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>所以</span><span><font face="Times New Roman">B-</font></span><span>树的性能总是等价于二分查找（与</span><span><font face="Times New Roman">M</font></span><span>值无关），也就没有</span><span><font face="Times New Roman">B</font></span><span>树平衡的问题；</span></font></p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>由于</span><span><font face="Times New Roman">M/2</font></span><span>的限制，在插入结点时，如果结点已满，需要将结点分裂为两个各占</span><span><font face="Times New Roman">M/2</font></span><span>的结点；删除结点时，需将两个不足</span><span><font face="Times New Roman">M/2</font></span><span>的兄弟结点合并；</span></font></p>
<p><span><font face="Times new roman" size="2">&nbsp;</font></span></p>
<p><span></span></p>
<p><font size="2"><span><font face="Times New Roman">B+</font></span><span>树</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>B+</font></span><span>树是</span><span><font face="Times New Roman">B-</font></span><span>树的变体，也是一种多路搜索树：</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>1.</font></span><span>其定义基本与</span><span><font face="Times New Roman">B-</font></span><span>树同，除了：</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>2.</font></span><span>非叶子结点的子树指针与关键字个数相同；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>3.</font></span><span>非叶子结点的子树指针</span><span><font face="Times New Roman">P[i]</font></span><span>，指向关键字值属于</span><span><font face="Times New Roman">[K[i], K[i+1])</font></span><span>的子树（</span><span><font face="Times New Roman">B-</font></span><span>树是开区间）；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>5.</font></span><span>为所有叶子结点增加一个链指针；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>6.</font></span><span>所有关键字都在叶子结点出现；</span></font></p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>如：（</span><span><font face="Times New Roman">M=3</font></span><span>）</span></font></p>
<p align="center"><font size="2"><span><span><img src="http://www.cppblog.com/images/cppblog_com/emptysoul/b7.JPG" border="0"></span></span></font></p>
<p><font size="2"><span>&nbsp;&nbsp; </span></font><font size="2"><span><font face="Times New Roman">B+</font></span><span>的搜索与</span><span><font face="Times New Roman">B-</font></span><span>树也基本相同，区别是</span><span><font face="Times New Roman">B+</font></span><span>树只有达到叶子结点才命中（</span><span><font face="Times New Roman">B-</font></span><span>树可以在非叶子结点命中），其性能也等价于在关键字全集做一次二分查找；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>B+</font></span><span>的特性：</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>1.</font></span><span>所有关键字都出现在叶子结点的链表中（稠密索引），且链表中的关键字恰好是有序的；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>2.</font></span><span>不可能在非叶子结点命中；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>3.</font></span><span>非叶子结点相当于是叶子结点的索引（稀疏索引），叶子结点相当于是存储（关键字）数据的数据层；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>4.</font></span><span>更适合文件索引系统；</span></font></p>
<p><span><font face="Times new roman" size="2">&nbsp;</font></span><span><font face="Times new roman" size="2">&nbsp;</font></span></p>
<p><font size="2"><span><font face="Times New Roman">B*</font></span><span>树</span></font></p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>是</span><span><font face="Times New Roman">B+</font></span><span>树的变体，在</span><span><font face="Times New Roman">B+</font></span><span>树的非根和非叶子结点再增加指向兄弟的指针；</span></font></p>
<p align="center"><font size="2"><span><span><img src="http://www.cppblog.com/images/cppblog_com/emptysoul/B8.JPG" border="0"></span></span></font></p>
<p><font size="2"><span>&nbsp;&nbsp; </span></font><font size="2"><span><font face="Times New Roman">B*</font></span><span>树定义了非叶子结点关键字个数至少为</span><span><font face="Times New Roman">(2/3)*M</font></span><span>，即块的最低使用率为</span><span><font face="Times New Roman">2/3</font></span><span>（代替</span><span><font face="Times New Roman">B+</font></span><span>树的</span><span><font face="Times New Roman">1/2</font></span><span>）；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>B+</font></span><span>树的分裂：当一个结点满时，分配一个新的结点，并将原结点中</span><span><font face="Times New Roman">1/2</font></span><span>的数据复制到新结点，最后在父结点中增加新结点的指针；</span><span><font face="Times New Roman">B+</font></span><span>树的分裂只影响原结点和父结点，而不会影响兄弟结点，所以它不需要指向兄弟的指针；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>B*</font></span><span>树的分裂：当一个结点满时，如果它的下一个兄弟结点未满，那么将一部分数据移到兄弟结点中，再在原结点插入关键字，最后修改父结点中兄弟结点的关键字（因为兄弟结点的关键字范围改变了）；如果兄弟也满了，则在原结点与兄弟结点之间增加新结点，并各复制</span><span><font face="Times New Roman">1/3</font></span><span>的数据到新结点，最后在父结点增加新结点的指针；</span></font></p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>所以，</span><span><font face="Times New Roman">B*</font></span><span>树分配新结点的概率比</span><span><font face="Times New Roman">B+</font></span><span>树要低，空间使用率更高；</span></font></p>
<p><span><font face="Times new roman" size="2">&nbsp;</font></span><span><font face="Times new roman" size="2">&nbsp;</font></span></p>
<p><span><font size="2">小结</font></span></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>B</font></span><span>树：二叉树，每个结点只存储一个关键字，等于则命中，小于走左结点，大于走右结点；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>B-</font></span><span>树：多路搜索树，每个结点存储</span><span><font face="Times New Roman">M/2</font></span><span>到</span><span><font face="Times New Roman">M</font></span><span>个关键字，非叶子结点存储指向关键字范围的子结点；</span></font></p>
<p><font size="2"><span><span><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span>所有关键字在整颗树中出现，且只出现一次，非叶子结点可以命中；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>B+</font></span><span>树：在</span><span><font face="Times New Roman">B-</font></span><span>树基础上，为叶子结点增加链表指针，所有关键字都在叶子结点中出现，非叶子结点作为叶子结点的索引；</span><span><font face="Times New Roman">B+</font></span><span>树总是到叶子结点才命中；</span></font></p>
<p><font size="2"><span><font face="Times New Roman"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>B*</font></span><span>树：在</span><span><font face="Times New Roman">B+</font></span><span>树基础上，为非叶子结点也增加链表指针，将结点的最低利用率从</span><span><font face="Times New Roman">1/2</font></span><span>提高到</span><span><font face="Times New Roman">2/3</font></span><span>。</span></font></p>
<p><font size="2"><span>转自: http://blog.csdn.net/manesking/archive/2007/02/09/1505979.aspx<br></span></font></p>
</span></font></span></font> <img src ="http://www.cppblog.com/Chipset/aggbug/71265.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Chipset/" target="_blank">山寨科技</a> 2009-01-05 23:45 <a href="http://www.cppblog.com/Chipset/archive/2009/01/05/71265.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>