{"id":7906,"date":"2023-01-28T13:20:22","date_gmt":"2023-01-28T05:20:22","guid":{"rendered":"https:\/\/egonlin.com\/?p=7906"},"modified":"2023-01-28T13:20:22","modified_gmt":"2023-01-28T05:20:22","slug":"10-%e8%bf%90%e7%ae%97%e7%ac%a6","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=7906","title":{"rendered":"10 \u8fd0\u7b97\u7b26"},"content":{"rendered":"<h1>\u8fd0\u7b97\u7b26\u4ecb\u7ecd<\/h1>\n<p>\u8fd0\u7b97\u7b26\u7528\u4e8e\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u6267\u884c\u6570\u5b66\u6216\u903b\u8f91\u8fd0\u7b97\uff0cGo \u8bed\u8a00\u5185\u7f6e\u7684\u8fd0\u7b97\u7b26\u6709\uff1a<\/p>\n<ul>\n<li>\u4e00\u5143\u8fd0\u7b97\u7b26\n<ul>\n<li><code>+<\/code>\u4e00\u5143\u52a0\u6cd5<\/li>\n<li><code>-<\/code>\u8d1f\u6570<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4e8c\u5143\u8fd0\u7b97\u7b26<\/p>\n<ul>\n<li>\n<p>\u7b97\u672f\u8fd0\u7b97\u7b26<\/p>\n<\/li>\n<li>\n<p>\u4f4d\u8fd0\u7b97\u7b26<\/p>\n<\/li>\n<li>\n<p>\u903b\u8f91\u8fd0\u7b97\u7b26<\/p>\n<\/li>\n<li>\n<p>\u6bd4\u8f83\u8fd0\u7b97\u7b26<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Go\u8bed\u8a00\u4e2d\u6240\u6709\u7684\u4e8c\u5143\u8fd0\u7b97\u7b26\u5171\u6709\u4e94\u79cd\u4f18\u5148\u7ea7\uff0c\u5982\u4e0b\u6240\u793a\uff0c\u5b83\u4eec\u6309\u7167\u4f18\u5148\u7ea7\u9012\u51cf\u7684\u987a\u5e8f\u7684\u6392\u5217\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u4f18\u5148\u7ea7<\/th>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>5<\/td>\n<td>* \/ % &lt;&lt; &gt;&gt; &amp; &amp;^<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>+ &#8211; | ^<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>== != &lt; &lt;= &gt; &gt;=<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>&amp;&amp;<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>||<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5728\u540c\u4e00\u4e2a\u4f18\u5148\u7ea7\uff0c\u4f7f\u7528\u5de6\u4f18\u5148\u7ed3\u5408\u89c4\u5219\uff0c\u4f46\u662f\u4f7f\u7528\u62ec\u53f7\u53ef\u4ee5\u63d0\u5347\u4f18\u5148\u7ea7\uff0c\u6240\u4ee5\u5efa\u8bae\u4f7f\u7528\u62ec\u53f7\u660e\u786e\u4f18\u5148\u987a\u5e8f\u3002<\/p>\n<h2>\u4e00\u3001 \u4e00\u5143\u8fd0\u7b97\u7b26<\/h2>\n<table>\n<thead>\n<tr>\n<th>\u4e00\u5143\u7684\u52a0\u6cd5\u548c\u51cf\u6cd5\u8fd0\u7b97\u7b26<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>+<\/td>\n<td>\u4e00\u5143\u52a0\u6cd5 (\u65e0\u6548\u679c)<\/td>\n<\/tr>\n<tr>\n<td>&#8211;<\/td>\n<td>\u8d1f\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5bf9\u4e8e\u6574\u6570\u3001\u6d6e\u70b9\u6570\u548c\u590d\u6570\uff0c+x\u5c31\u662fx\uff0c-x\u5219\u662fx \u7684\u8d1f\u6570\u3002\u4f8b\u5982+(-8)\u5f97-8<\/p>\n<table>\n<thead>\n<tr>\n<th>\u4e00\u5143\u6307\u9488\u8fd0\u7b97\u7b26<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u5b9e\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>&amp;<\/td>\n<td>\u8fd4\u56de\u53d8\u91cf\u5b58\u50a8\u5730\u5740<\/td>\n<td>&a; \u5c06\u7ed9\u51fa\u53d8\u91cf\u7684\u5b9e\u9645\u5730\u5740\u3002<\/td>\n<\/tr>\n<tr>\n<td>*<\/td>\n<td>\u6307\u9488\u53d8\u91cf\u3002<\/td>\n<td>*a; \u662f\u4e00\u4e2a\u6307\u9488\u53d8\u91cf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4e8c\u3001 \u4e8c\u5143\u8fd0\u7b97\u7b26<\/h2>\n<h3>2.1 \u4e8c\u5143\u8fd0\u7b97\u7684\u91cd\u8981\u539f\u5219<\/h3>\n<p>\u91cd\u7533\u6211\u4eec\u4e4b\u524d\u5b66\u8fc7\u7684\u4e00\u4e2a\u91cd\u8981\u539f\u5219\uff0c\u5982\u4e0b\u6240\u793a<\/p>\n<ul>\n<li><strong>go\u662f\u5f3a\u7c7b\u578b\u8bed\u8a00\uff0c\u8fd0\u7b97\u5fc5\u987b\u662f\u540c\u7c7b\u578b\u4e4b\u95f4\u8fdb\u884c\uff0c\u5373\u4fbf\u6d89\u53ca\u5230\u65e0\u7c7b\u578b\u7684\u91cf\uff08\u5047\u8bbe\u4e3ax\uff09go\u4e5f\u4f1a\u5c06\u5176\u5148\u9690\u5f0f\u8f6c\u6362\u6210\u76f8\u540c\u7684\u7c7b\u578b\u624d\u80fd\u8fdb\u884c\u540e\u8fd0\uff0c\u800c\u8f6c\u6362\u662f\u5426\u5408\u6cd5\uff0c\u5224\u65ad\u7684\u4f9d\u636e\u662f\u663e\u5f0f\u8f6c\u6362T(x)\u662f\u5426\u5408\u6cd5\uff0c\u56e0\u4e3a\u5e95\u5c42\u53d1\u751f\u7684\u5c31\u662f\u9690\u5f0f\u7684T(x)\u8f6c\u6362\u3002<\/strong><\/li>\n<\/ul>\n<p>\u9664\u4e86\u4f4d\u8fd0\u7b97\u4e4b\u5916\uff0c\u4e8c\u5143\u8fd0\u7b97\u4e2d\u7684\u7b97\u6570\u8fd0\u7b97\u3001\u8d4b\u503c\u8fd0\u7b97\u3001\u6bd4\u8f83\u8fd0\u7b97\u7b26\u6d89\u53ca\u5230\u591a\u4e2a\u91cf\u8fdb\u884c\u8fd0\u7b97\uff0c\u5fc5\u987b\u9075\u5faa\u4e0a\u8ff0\u89c4\u5219\u3002<\/p>\n<h3>2.2 \u7b97\u6570\u8fd0\u7b97\u7b26<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>+<\/td>\n<td>\u76f8\u52a0<\/td>\n<\/tr>\n<tr>\n<td>&#8211;<\/td>\n<td>\u76f8\u51cf<\/td>\n<\/tr>\n<tr>\n<td>*<\/td>\n<td>\u76f8\u4e58<\/td>\n<\/tr>\n<tr>\n<td>\/<\/td>\n<td>\u76f8\u9664<\/td>\n<\/tr>\n<tr>\n<td>%<\/td>\n<td>\u6c42\u4f59\/\u53d6\u6a21<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\n<p>1\u3001\u7b97\u672f\u8fd0\u7b97\u7b26+\u3001-\u3001<code>*<\/code>\u548c<code>\/<\/code>\u53ef\u4ee5\u5728\u6574\u6570\u3001\u6d6e\u70b9\u6570\u548c\u590d\u6570\u7684\u5b57\u9762\u503c\u4e4b\u95f4\u6df7\u7528\uff0c\u4f46\u662f\u53d6\u6a21\u8fd0\u7b97\u7b26%\u4ec5\u7528\u4e8e\u6574\u6570\u95f4\u7684\u8fd0\u7b97<\/p>\n<pre><code class=\"language-go\">fmt.Println(3 % 2) \/\/ 1\nfmt.Println(3.1 % 2) \/\/ \u62a5\u9519\uff1aoperator % not defined on untyped float<\/code><\/pre>\n<\/li>\n<li>\n<p>2\u3001\u5728Go\u8bed\u8a00\u4e2d\uff0c%\u53d6\u6a21\u8fd0\u7b97\u7b26\u7684\u7b26\u53f7\u548c\u88ab\u53d6\u6a21\u6570\u7684\u7b26\u53f7\u603b\u662f\u4e00\u81f4\u7684\uff0c\u56e0\u6b64<code>-5%3<\/code>\u548c<code>-5%-3<\/code>\u7ed3\u679c\u90fd\u662f-2\u3002<\/p>\n<pre><code class=\"language-go\">\/\/ \u53ef\u4ee5\u8fd9\u505a\n-(-5 % -3)<\/code><\/pre>\n<\/li>\n<li>\n<p>3\u3001\u9664\u6cd5\u8fd0\u7b97\u7b26<code>\/<\/code>\u7684\u884c\u4e3a\u5219\u4f9d\u8d56\u4e8e\u64cd\u4f5c\u6570\u662f\u5426\u4e3a\u5168\u4e3a\u6574\u6570\uff0c\u4f8b\u5982<\/p>\n<pre><code class=\"language-go\">fmt.Println(8.0 \/ 5.0) \/\/ \u7ed3\u679c\u4e3a1.6\nfmt.Println(8 \/ 5.0)  \/\/ \u7ed3\u679c\u4e3a1.6\nfmt.Println(8.0 \/ 5) \/\/ \u7ed3\u679c\u4e3a1.6\n\nfmt.Println(8 \/ 5)  \/\/ \u7ed3\u679c\u4e3a1\uff0c\u56e0\u4e3a\u6574\u6570\u9664\u6cd5\u4f1a\u5411\u77400\u65b9\u5411\u622a\u65ad\u4f59\u6570\u3002<\/code><\/pre>\n<\/li>\n<li>\n<p>4\u3001\u56e0\u4e3a\u9664\u6cd5\u8fd0\u7b97\u7b26\/\u4f1a\u6839\u636e\u64cd\u4f5c\u6570\u7684\u7c7b\u578b\u751f\u6210\u5bf9\u5e94\u7c7b\u578b\u7684\u7ed3\u679c\uff0c\u6240\u4ee5\u4e0d\u540c\u5199\u6cd5\u7684\u5e38\u91cf\u9664\u6cd5\u8868\u8fbe\u5f0f\u53ef\u80fd\u5bf9\u5e94\u4e0d\u540c\u7684\u7ed3\u679c\uff1a<\/p>\n<pre><code class=\"language-go\">var f float64 = 212\nfmt.Println((f - 32) * 5 \/ 9)     \/\/ \"100\"; (f - 32) * 5 \u5f97\u5230\u7684\u662f\u6d6e\u70b9\u578b\n\nfmt.Println(5 \/ 9 * (f - 32))     \/\/ \"0\";   5\/9 \u5f97\u5230\u7684\u662f\u6574\u578b\nfmt.Println(5.0 \/ 9.0 * (f - 32)) \/\/ \"100\"; 5.0\/9.0 \u5f97\u5230\u7684\u662f\u6d6e\u70b9\u578b<\/code><\/pre>\n<\/li>\n<li>\n<p>5\u3001\u9488\u5bf9\u4e00\u4e2a\u7b97\u672f\u8fd0\u7b97\u7684\u7ed3\u679c\uff0c\u4e0d\u7ba1\u662f\u6709\u7b26\u53f7\u8fd8\u662f\u65e0\u7b26\u53f7\u7684\uff0c\u5982\u679c\u9700\u8981\u66f4\u591a\u7684bit\u4f4d\u624d\u80fd\u6b63\u786e\u8868\u793a\u7684\u8bdd\uff0c\u5c31\u8bf4\u660e\u8ba1\u7b97\u7ed3\u679c\u662f\u6ea2\u51fa\u4e86\uff0c\u800c\u8d85\u51fa\u7684\u9ad8\u4f4d\u7684bit\u4f4d\u90e8\u5206\u5c06\u88ab\u4e22\u5f03\uff0c\u4e5f\u5c31\u662f\u8bf4\u5982\u679c\u539f\u59cb\u7684\u6570\u503c\u662f\u6709\u7b26\u53f7\u7c7b\u578b\uff0c\u800c\u4e14\u6700\u5de6\u8fb9\u7684bit\u4e3a\u662f1\u7684\u8bdd\uff0c\u90a3\u4e48\u6700\u7ec8\u7ed3\u679c\u5c31\u53ef\u80fd\u662f\u8d1f\u7684\uff0c\u4f8b\u5982int8\u7684\u4f8b\u5b50\uff1a<\/p>\n<pre><code class=\"language-go\">var u uint8 = 255\nfmt.Println(u, u+1, u*u) \/\/ \"255 0 1\"\n\nvar i int8 = 127\nfmt.Println(i, i+1, i*i) \/\/ \"127 -128 1\"<\/code><\/pre>\n<p>\uff1f\uff1f\uff1f\u4e3a\u4f55\u51fa\u73b0128\u5462\uff0cegon\u6765\u5148\u626b\u4e00\u4e0b\u76f2\uff0c\u4f30\u8ba1\u4f1a\u626b\u6b7b99%\u7684\u4eba<\/p>\n<pre><code class=\"language-go\">\u95ee\uff1a8\u4f4d\u4e8c\u8fdb\u5236\u6570\u53ef\u4ee5\u8868\u793a\u7684\u6570\u503c\u8303\u56f4\u662f\u591a\u5c11\uff0c99%\u7684\u4eba\u5f20\u53e3\u5c31\u6765\uff1a-128~127\n\n\u200b ok\uff0c8\u4f4d\u4e8c\u8fdb\u5236\u6570\uff0c\u6700\u9ad8\u4f4d\u9700\u8981\u7528\u6765\u8868\u793a\u7b26\u53f7\uff0c\u90a3\u4e48\u5269\u4e0b\u76847\u4f4d\u7528\u6765\u8868\u793a\u6570\u503c\n\n\u200b \u4e8e\u662f\uff0c\u6700\u5927\u6570\u4e3a1111 1111=>+127\uff0c\u6700\u5c0f0111 1111=>-127\uff0c\u5367\u69fd\uff0c\u5f97\u51fa\u7684\u7ed3\u8bba\u662f8\u4f4d\u4e8c\u8fdb\u5236\u6570\u53ef\u4ee5\u8868\u793a\u7684\u6570\u503c\u8303\u56f4\u662f-127\u5230+127\uff0c\u50bb\u903c\u4e86\u5427\u4f60\uff0c\u54c8\u54c8\u54c8\n\n\u200b \u7075\u9b42\u62f7\u95ee\uff1a-128\u5230\u5e95\u600e\u4e48\u6765\u7684\uff1f\uff1f\uff1f\n\n\u200b  \u771f\u76f8\u662f\u8fd9\u6837\u7684\uff1a\n 8\u4f4d\u4e8c\u8fdb\u5236\u6570\u75287\u4f4d\u8868\u793a\u6570\u503c\uff0c\u90a3\u4e487\u4f4d2\u8fdb\u5236\u6570000 0000\u7684\u503c\u4e3a0\n \u90a3\u4e48,\u5b83\u524d\u9762\u52a0\u4e0a\u7b26\u53f7\u4f4d0,\u8fd8\u8868\u793a0\u5427?\n \u90a3\u597d,\u5982\u679c\u5b83\u524d\u9762\u52a0\u4e0a1\u5462,\u4ecd\u7136\u8868\u793a0?\u8fd9\u4e0d\u662f\u91cd\u590d\u4e86\u4e48?\n \u4e00\u4e2a0,\u600e\u4e48\u7528\u4e24\u4e2a\u503c\u6765\u8868\u793a\u5462\uff01\uff01\uff01\n \u6240\u4ee51000 0000\u5c31\u8868\u793a-128\u5566\uff0c<\/code><\/pre>\n<\/li>\n<li>\n<p>6\u3001\u5b57\u7b26\u4e32\u4e5f\u53ef\u4ee5\u4f7f\u7528+\u8fd0\u7b97\u7b26<\/p>\n<p>\u5176\u4e2d+\u64cd\u4f5c\u7b26\u5c06\u4e24\u4e2a\u5b57\u7b26\u4e32\u94fe\u63a5\u6784\u9020\u4e00\u4e2a\u65b0\u5b57\u7b26\u4e32\uff1a<\/p>\n<pre><code class=\"language-Go\">fmt.Println(\"goodbye\" + s[5:]) \/\/ \"goodbye, world\"<\/code><\/pre>\n<p>\u5b57\u7b26\u4e32\u7684\u503c\u662f\u4e0d\u53ef\u53d8\u7684\uff1a\u4e00\u4e2a\u5b57\u7b26\u4e32\u5305\u542b\u7684\u5b57\u8282\u5e8f\u5217\u6c38\u8fdc\u4e0d\u4f1a\u88ab\u6539\u53d8\uff0c\u5f53\u7136\u6211\u4eec\u4e5f\u53ef\u4ee5\u7ed9\u4e00\u4e2a\u5b57\u7b26\u4e32\u53d8\u91cf\u5206\u914d\u4e00\u4e2a\u65b0\u5b57\u7b26\u4e32\u503c\u3002\u53ef\u4ee5\u50cf\u4e0b\u9762\u8fd9\u6837\u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u8ffd\u52a0\u5230\u53e6\u4e00\u4e2a\u5b57\u7b26\u4e32\uff1a<\/p>\n<pre><code class=\"language-Go\">s := \"left foot\"\nt := s\ns += \", right foot\"<\/code><\/pre>\n<p>\u8fd9\u5e76\u4e0d\u4f1a\u5bfc\u81f4\u539f\u59cb\u7684\u5b57\u7b26\u4e32\u503c\u88ab\u6539\u53d8\uff0c\u4f46\u662f\u53d8\u91cfs\u5c06\u56e0\u4e3a+=\u8bed\u53e5\u6301\u6709\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32\u503c\uff0c\u4f46\u662ft\u4f9d\u7136\u662f\u5305\u542b\u539f\u5148\u7684\u5b57\u7b26\u4e32\u503c\u3002<\/p>\n<pre><code class=\"language-Go\">fmt.Println(s) \/\/ \"left foot, right foot\"\nfmt.Println(t) \/\/ \"left foot\"<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>2.3 \u4f4d\u8fd0\u7b97\u7b26<\/h3>\n<p>\u4f4d\u8fd0\u7b97\u7b26\u5bf9\u6574\u6570\u5728\u5185\u5b58\u4e2d\u7684\u4e8c\u8fdb\u5236\u4f4d\u8fdb\u884c\u64cd\u4f5c\uff08\u8be6\u89e3\u9644\u5f55\uff1a\u4f4d\u8fd0\u7b97\uff09<\/p>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u5b9e\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>&lt;&lt;<\/td>\n<td>\u5de6\u79fb\uff0c\u5de6\u79fbn\u4f4d\u5c31\u662f\u4e58\u4ee52\u7684n\u6b21\u65b9\u3002 \u201ca&lt;&lt;b\u201d\u662f\u628aa\u7684\u5404\u4e8c\u8fdb\u4f4d\u5168\u90e8\u5de6\u79fbb\u4f4d\uff0c\u9ad8\u4f4d\u4e22\u5f03\uff0c\u4f4e\u4f4d\u88650\u3002<\/td>\n<td>A &lt;&lt; 2 \u7ed3\u679c\u4e3a 240 \uff0c\u4e8c\u8fdb\u5236\u4e3a 1111 0000<\/td>\n<\/tr>\n<tr>\n<td>&gt;&gt;<\/td>\n<td>\u53f3\u79fb\uff0c\u53f3\u79fbn\u4f4d\u5c31\u662f\u9664\u4ee52\u7684n\u6b21\u65b9\u3002 \u201ca&gt;&gt;b\u201d\u662f\u628aa\u7684\u5404\u4e8c\u8fdb\u4f4d\u5168\u90e8\u53f3\u79fbb\u4f4d\u3002<\/td>\n<td>A &gt;&gt; 2 \u7ed3\u679c\u4e3a 15 \uff0c\u4e8c\u8fdb\u5236\u4e3a 0000 1111<\/td>\n<\/tr>\n<tr>\n<td>&amp;<\/td>\n<td>\u4f4d\u8fd0\u7b97AND\uff0c\u53c2\u4e0e\u8fd0\u7b97\u7684\u4e24\u6570\u5404\u5bf9\u5e94\u7684\u4e8c\u8fdb\u4f4d\u76f8\u4e0e\u3002 \uff08\u4e24\u4f4d\u5747\u4e3a1\u624d\u4e3a1\uff09<\/td>\n<td>(A &amp; B) \u7ed3\u679c\u4e3a 12, \u4e8c\u8fdb\u5236\u4e3a 0000 1100<\/td>\n<\/tr>\n<tr>\n<td>|<\/td>\n<td>\u4f4d\u8fd0\u7b97OR\uff0c\u53c2\u4e0e\u8fd0\u7b97\u7684\u4e24\u6570\u5404\u5bf9\u5e94\u7684\u4e8c\u8fdb\u4f4d\u76f8\u6216\u3002 \uff08\u4e24\u4f4d\u6709\u4e00\u4e2a\u4e3a1\u5c31\u4e3a1\uff09<\/td>\n<td>(A | B) \u7ed3\u679c\u4e3a 61, \u4e8c\u8fdb\u5236\u4e3a 0011 1101<\/td>\n<\/tr>\n<tr>\n<td>^<\/td>\n<td>\u4f4d\u8fd0\u7b97XOR\uff0c\u53c2\u4e0e\u8fd0\u7b97\u7684\u4e24\u6570\u5404\u5bf9\u5e94\u7684\u4e8c\u8fdb\u4f4d\u76f8\u5f02\u6216\uff0c\u5f53\u4e24\u5bf9\u5e94\u7684\u4e8c\u8fdb\u4f4d\u76f8\u5f02\u65f6\uff0c\u7ed3\u679c\u4e3a1\u3002 \uff08\u4e24\u4f4d\u4e0d\u4e00\u6837\u5219\u4e3a1\uff09<\/td>\n<td>(A ^ B) \u7ed3\u679c\u4e3a 49, \u4e8c\u8fdb\u5236\u4e3a 0011 0001<\/td>\n<\/tr>\n<tr>\n<td>&amp;^<\/td>\n<td>\u4f4d\u6e05\u7a7a (AND NOT)<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u6ce8\u610f\uff1an\u6b21\u65b9\u8fd0\u7b97\u4e0d\u662f^\uff0c\u800c\u662fmath.Pow()\uff0c\u5982\u4e0b\u6240\u793a<\/strong><\/p>\n<pre><code class=\"language-go\">var aaa =  math.Pow(10,38)  \/\/ 10\u768438\u6b21\u65b9\nfmt.Printf(&quot;%T,%v\\n&quot;,aaa,aaa)  \/\/ float64,1e+38<\/code><\/pre>\n<h3>2.4 \u8d4b\u503c\u8fd0\u7b97\u7b26<\/h3>\n<p>\u5bf9\u4e8e\u7b97\u6570\u8fd0\u7b97\u7b26\u548c\u4f4d\u8fd0\u7b97\u7b26\uff0c\u8fd8\u7ed3\u5408\u8d4b\u503c\u7b26\u53f7\u4e66\u5199\u6210\u7b80\u5316\u7684\u8d4b\u503c\u8bed\u53e5\uff0c\u4f8b\u5982+\u8fd0\u7b97\u7b26\u8fd8\u6709\u4e00\u4e2a\u4e0e\u8d4b\u503c\u76f8\u7ed3\u5408\u7684\u5bf9\u5e94\u8fd0\u7b97\u7b26+=<\/p>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>=<\/td>\n<td>\u7b80\u5355\u7684\u8d4b\u503c\u8fd0\u7b97\u7b26\uff0c\u5c06\u4e00\u4e2a\u8868\u8fbe\u5f0f\u7684\u503c\u8d4b\u7ed9\u4e00\u4e2a\u5de6\u503c<\/td>\n<\/tr>\n<tr>\n<td>+=<\/td>\n<td>\u76f8\u52a0\u540e\u518d\u8d4b\u503c<\/td>\n<\/tr>\n<tr>\n<td>-=<\/td>\n<td>\u76f8\u51cf\u540e\u518d\u8d4b\u503c<\/td>\n<\/tr>\n<tr>\n<td>*=<\/td>\n<td>\u76f8\u4e58\u540e\u518d\u8d4b\u503c<\/td>\n<\/tr>\n<tr>\n<td>\/=<\/td>\n<td>\u76f8\u9664\u540e\u518d\u8d4b\u503c<\/td>\n<\/tr>\n<tr>\n<td>%=<\/td>\n<td>\u6c42\u4f59\u540e\u518d\u8d4b\u503c<\/td>\n<\/tr>\n<tr>\n<td>&lt;&lt;=<\/td>\n<td>\u5de6\u79fb\u540e\u8d4b\u503c<\/td>\n<\/tr>\n<tr>\n<td>&gt;&gt;=<\/td>\n<td>\u53f3\u79fb\u540e\u8d4b\u503c<\/td>\n<\/tr>\n<tr>\n<td>&amp;=<\/td>\n<td>\u6309\u4f4d\u4e0e\u540e\u8d4b\u503c<\/td>\n<\/tr>\n<tr>\n<td>|=<\/td>\n<td>\u6309\u4f4d\u6216\u540e\u8d4b\u503c<\/td>\n<\/tr>\n<tr>\n<td>^=<\/td>\n<td>\u6309\u4f4d\u5f02\u6216\u540e\u8d4b\u503c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u6ce8\u610f1\uff1a <\/strong><\/p>\n<p>\u5728Go\u8bed\u6cd5\u4e2d\uff0c\u53d8\u91cf\u521d\u59cb\u5316\u548c\u53d8\u91cf\u8d4b\u503c\u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u6982\u5ff5\u3002\u4e0b\u9762\u4e3a\u58f0\u660e\u4e00\u4e2a\u53d8\u91cf\u4e4b\u540e\u7684\u8d4b\u503c<br \/>\n\u8fc7\u7a0b\uff1a<\/p>\n<pre><code class=\"language-go\">var v int\nv = 123<\/code><\/pre>\n<p>Go\u8bed\u8a00\u7684\u53d8\u91cf\u8d4b\u503c\u4e0e\u591a\u6570\u8bed\u8a00\u4e00\u81f4\uff0c\u4f46Go\u8bed\u8a00\u4e2d\u63d0\u4f9b\u4e86C\/C++\u7a0b\u5e8f\u5458\u671f\u76fc\u591a\u5e74\u7684\u591a\u91cd\u8d4b\u503c\u529f<br \/>\n\u80fd\uff0c\u6bd4\u5982\u4e0b\u9762\u8fd9\u4e2a\u4ea4\u6362i\u548cj\u53d8\u91cf\u7684\u8bed\u53e5\uff1a<\/p>\n<pre><code class=\"language-go\">i, j = j, i\n\n\/\/ \u5728\u4e0d\u652f\u6301\u591a\u91cd\u8d4b\u503c\u7684\u8bed\u8a00\u4e2d\uff0c\u4ea4\u4e92\u4e24\u4e2a\u53d8\u91cf\u7684\u5185\u5bb9\u9700\u8981\u5f15\u5165\u4e00\u4e2a\u4e2d\u95f4\u53d8\u91cf\uff1a\nt = i; i = j; j = t;<\/code><\/pre>\n<p>\u591a\u91cd\u8d4b\u503c\u7684\u7279\u6027\u5728Go\u8bed\u8a00\u5e93\u7684\u5b9e\u73b0\u4e2d\u4e5f\u88ab\u4f7f\u7528\u5f97\u76f8\u5f53\u5145\u5206\uff0c\u5728\u4ecb\u7ecd\u51fd\u6570\u7684\u591a\u91cd\u8fd4\u56de\u503c\u65f6\uff0c<br \/>\n\u5c06\u5bf9\u5176\u8fdb\u884c\u66f4\u52a0\u6df1\u5165\u7684\u4ecb\u7ecd\u3002\u603b\u800c\u8a00\u4e4b\uff0c\u591a\u91cd\u8d4b\u503c\u529f\u80fd\u8ba9Go\u8bed\u8a00\u4e0eC\/C++\u8bed\u8a00\u76f8\u6bd4\u53ef\u4ee5\u975e\u5e38\u660e\u663e<br \/>\n\u5730\u51cf\u5c11\u4ee3\u7801\u884c\u6570\u3002\u591a\u91cd\u8d4b\u503c\u7ec6\u8282\u548c\u539f\u7406\u53c2\u7167\u5b98\u65b9\u6587\u6863golang\u5b98\u7f51\uff1a<a href=\"https:\/\/golang.org\/ref\/spec#Constants\">https:\/\/golang.org\/ref\/spec#Constants<\/a><\/p>\n<p><strong>\u6ce8\u610f2\uff1a<\/strong><\/p>\n<p>\u518d\u6b21\u91cd\u7533\uff0cgo\u662f\u5f3a\u7c7b\u578b\uff0c\u4f46\u51e1\u6d89\u53ca\u5230\u4e24\u4e2a\u53d8\u91cf\u7684\u64cd\u4f5c\uff0c\u5fc5\u987b\u662f\u540c\u7c7b\u578b\u4e4b\u95f4\u624d\u884c\uff0c\u56e0\u4e3a\u76f8\u540c\u7684\u7c7b\u578b\u5e95\u5c42\u7684\u5185\u5b58\u6570\u636e\u7ed3\u6784\u624d\u4e00\u6837\u3002\u8d4b\u503c\u64cd\u4f5c\u5c31\u6d89\u53ca\u5230\u4e86\u4e24\u4e2a\u53d8\u91cf<\/p>\n<pre><code class=\"language-go\">var x [3]int = [3]int{11,22,33}\nvar y [2]int = [2]int{11,22}\nx = y  \/\/ \u9519\u8bef<\/code><\/pre>\n<p><strong>\u6ce8\u610f3<\/strong>\uff1a<\/p>\n<pre><code class=\"language-go\">\uff1a=\u8981\u6c42\u7b49\u53f7\u5de6\u8fb9\u5fc5\u987b\u81f3\u5c11\u6709\u4e00\u4e2a\u65b0\u53d8\u91cf\n\u800c\u533f\u540d\u53d8\u91cf_\u4e0d\u662f\u65b0\u53d8\u91cf\uff0c\u6240\u4ee5\u5f53\u5de6\u8fb9\u53ea\u6709\u4e00\u4e2a_\u65f6\u4f1a\u62a5\u9519\n\n_=&quot;egon&quot;  \/\/ \u8fd9\u4e2a\u662fok\u7684\uff0c\u56e0\u4e3a\u662f\u8d4b\u503c\u64cd\u4f5c\n_:=&quot;egon&quot;  \/\/ \u8fd9\u4e2a\u5c31\u4e0d\u884c<\/code><\/pre>\n<p><strong>\u6ce8\u610f4\uff1a <\/strong>\u6570\u503c\u53d8\u91cf\u4e5f\u53ef\u4ee5\u652f\u6301<code>++<\/code>\u9012\u589e\u548c<code>--<\/code>\u9012\u51cf\u8bed\u53e5\uff08\u8bd1\u6ce8\uff1a\u81ea\u589e\u548c\u81ea\u51cf\u662f\u8bed\u53e5\uff0c\u800c\u4e0d\u662f\u8868\u8fbe\u5f0f\u6216\u8fd0\u7b97\u7b26\uff0c\u56e0\u6b64<code>x = i++<\/code>\u4e4b\u7c7b\u7684\u8868\u8fbe\u5f0f\u662f\u9519\u8bef\u7684\u3002\u8bed\u53e5\u53ea\u662f\u6267\u884c\u6307\u4ee4\uff0c\u8868\u8fbe\u5f0f\u662f\u5728\u6267\u884c\u8ba1\u7b97\u4f1a\u6709\u8fd4\u56de\u503c\uff09\uff1a<\/p>\n<pre><code class=\"language-go\">x:=123\ny:=-3.1\n\nx--  \/\/ \u7b49\u4ef7\u4e8e x = x - 1\uff1bx \u53d8\u6210 122 \ny++  \/\/ \u7b49\u7ea7\u4e8e y = y + 1\uff1by \u53d8\u6210 -2.1\n\nfmt.Println(x) \/\/ 122\nfmt.Println(y) \/\/ -2.1<\/code><\/pre>\n<h3>2.5 \u6bd4\u8f83\u8fd0\u7b97\u7b26<\/h3>\n<p>\u6bd4\u8f83\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u662f\u5e03\u5c14\u7c7b\u578b<\/p>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>==<\/td>\n<td>\u68c0\u67e5\u4e24\u4e2a\u503c\u662f\u5426\u76f8\u7b49\uff0c\u5982\u679c\u76f8\u7b49\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n<tr>\n<td>!=<\/td>\n<td>\u68c0\u67e5\u4e24\u4e2a\u503c\u662f\u5426\u4e0d\u76f8\u7b49\uff0c\u5982\u679c\u4e0d\u76f8\u7b49\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n<tr>\n<td>&gt;<\/td>\n<td>\u68c0\u67e5\u5de6\u8fb9\u503c\u662f\u5426\u5927\u4e8e\u53f3\u8fb9\u503c\uff0c\u5982\u679c\u662f\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n<tr>\n<td>&gt;=<\/td>\n<td>\u68c0\u67e5\u5de6\u8fb9\u503c\u662f\u5426\u5927\u4e8e\u7b49\u4e8e\u53f3\u8fb9\u503c\uff0c\u5982\u679c\u662f\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n<tr>\n<td>&lt;<\/td>\n<td>\u68c0\u67e5\u5de6\u8fb9\u503c\u662f\u5426\u5c0f\u4e8e\u53f3\u8fb9\u503c\uff0c\u5982\u679c\u662f\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n<tr>\n<td>&lt;=<\/td>\n<td>\u68c0\u67e5\u5de6\u8fb9\u503c\u662f\u5426\u5c0f\u4e8e\u7b49\u4e8e\u53f3\u8fb9\u503c\uff0c\u5982\u679c\u662f\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\uff01\uff01\uff01\uff01\uff01\uff01\u6ce8\u610f\uff01\uff01\uff01\uff01\uff01\uff01<\/p>\n<ul>\n<li>\n<p>1\u3001\u76f8\u7b49\u6027\u5224\u65ad\u6211\u4eec\u5c06\u5728\u968f\u540e\u8be6\u7ec6\u4ecb\u7ecd\u6bcf\u79cd\u6570\u636e\u7c7b\u578b\u65f6\u8be6\u7ec6\u4ecb\u7ecd<\/p>\n<\/li>\n<li>\n<p>2\u3001\u901a\u5e38\u53ea\u6709\u540c\u7c7b\u578b\u7684<strong>\u6570\u5b57<\/strong>\u4e4b\u95f4\u3001\u6216\u8005\u4e0e\u6570\u5b57\u5b57\u9762\u91cf\u624d\u53ef\u4ee5\u6bd4\u5927\u5c0f\uff0c\u6bd4\u8f83\u7279\u6b8a\u7684\u662f\uff1a\u5b57\u7b26\u4e32\u662f\u53ef\u4ee5\u6bd4\u5927\u5c0f\uff0c\u4f1a\u6309\u6b21\u5e8f\u6bd4\u8f83\u5b57\u8282\uff0c\u800c\u4e0d\u662f\u5b57\u7b26\uff0c\u8fd9\u4e00\u70b9\u6211\u4eec\u5c06\u5728\u5b57\u7b26\u4e32\u7ae0\u8282\u8be6\u7ec6\u4ecb\u7ecd\uff1b<\/p>\n<\/li>\n<\/ul>\n<h3>2.6 \u903b\u8f91\u8fd0\u7b97\u7b26<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>&amp;&amp;<\/td>\n<td>\u903b\u8f91 AND \u8fd0\u7b97\u7b26\u3002 \u5982\u679c\u4e24\u8fb9\u7684\u64cd\u4f5c\u6570\u90fd\u662f True\uff0c\u5219\u4e3a True\uff0c\u5426\u5219\u4e3a False\u3002<\/td>\n<\/tr>\n<tr>\n<td>||<\/td>\n<td>\u903b\u8f91 OR \u8fd0\u7b97\u7b26\u3002 \u5982\u679c\u4e24\u8fb9\u7684\u64cd\u4f5c\u6570\u6709\u4e00\u4e2a True\uff0c\u5219\u4e3a True\uff0c\u5426\u5219\u4e3a False\u3002<\/td>\n<\/tr>\n<tr>\n<td>!<\/td>\n<td>\u903b\u8f91 NOT \u8fd0\u7b97\u7b26\u3002 \u5982\u679c\u6761\u4ef6\u4e3a True\uff0c\u5219\u4e3a False\uff0c\u5426\u5219\u4e3a True\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\uff01\u3001&amp;&amp;\u3001||<\/p>\n<pre><code class=\"language-go\">\u4f18\u5148\u7ea7! &gt; &amp;&amp; &gt; ||\uff0c\u63a8\u8350\u7528()\u6765\u63d0\u5347\u4f18\u5148\u7ea7\n\u8fde\u63a5\u591a\u4e2a\u6761\u4ef6\u65f6\u6709\u77ed\u8def\u884c\u4e3a<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd0\u7b97\u7b26\u4ecb\u7ecd \u8fd0\u7b97\u7b26\u7528\u4e8e\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u6267\u884c\u6570\u5b66\u6216\u903b\u8f91\u8fd0\u7b97\uff0cGo \u8bed\u8a00\u5185\u7f6e\u7684\u8fd0\u7b97\u7b26\u6709\uff1a \u4e00\u5143\u8fd0\u7b97\u7b26 +\u4e00\u5143\u52a0\u6cd5 -\u8d1f [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,447],"tags":[],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/7906"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7906"}],"version-history":[{"count":0,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/7906\/revisions"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}