{"id":40169,"date":"2023-10-05T23:49:17","date_gmt":"2023-10-05T15:49:17","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=40169"},"modified":"2023-10-05T23:49:17","modified_gmt":"2023-10-05T15:49:17","slug":"iygzjzijsylhyy","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/40169.html","title":{"rendered":"i\u4e00\u4e2a\u5b57\u8282\u8f6cint\uff1a\u4ecb\u7ecd\u3001\u539f\u7406\u548c\u5e94\u7528"},"content":{"rendered":"

  i\u4e00\u4e2a\u5b57\u8282\u8f6cint\uff08\u53c8\u79f0\u4e3a\u5b57\u8282\u8f6c\u6362\uff09\u662f\u4e00\u79cd\u5e38\u7528\u7684\u6570\u636e\u8f6c\u6362\u6280\u672f\uff0c\u5b83\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5b57\u8282\u7684\u6570\u636e\u8f6c\u6362\u4e3a\u4e00\u4e2a\u6574\u6570\u3002\u8fd9\u79cd\u6280\u672f\u5728\u8ba1\u7b97\u673a\u7f16\u7a0b\u4e2d\u975e\u5e38\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5c06\u5b57\u8282\u6d41\u8f6c\u6362\u4e3a\u53ef\u8bfb\u7684\u6574\u6570\u5f62\u5f0f\uff0c\u4ece\u800c\u5b9e\u73b0\u66f4\u7cbe\u786e\u7684\u6570\u636e\u64cd\u4f5c\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecdi\u4e00\u4e2a\u5b57\u8282\u8f6cint\u7684\u539f\u7406\u3001\u5e94\u7528\u548c\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n

\u4e00\u3001\u4ecb\u7ecd<\/h2>\n

  i\u4e00\u4e2a\u5b57\u8282\u8f6cint\uff0c\u53c8\u79f0\u4e3a\u5b57\u8282\u8f6c\u6362\uff0c\u662f\u4e00\u79cd\u6570\u636e\u8f6c\u6362\u6280\u672f\uff0c\u5b83\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5b57\u8282\u7684\u6570\u636e\u8f6c\u6362\u4e3a\u4e00\u4e2a\u6574\u6570\u3002\u5b83\u7684\u57fa\u672c\u539f\u7406\u662f\u5c06\u4e00\u4e2a\u5b57\u8282\u7684\u4e8c\u8fdb\u5236\u6570\u636e\u5206\u89e3\u4e3a8\u4e2a\u4f4d\uff0c\u5e76\u5c06\u6bcf\u4e00\u4f4d\u8f6c\u6362\u4e3a\u4e00\u4e2a\u6574\u6570\u3002\u6bd4\u5982\uff0c\u5982\u679c\u4e00\u4e2a\u5b57\u8282\u7684\u4e8c\u8fdb\u5236\u6570\u636e\u4e3a00000101\uff0c\u90a3\u4e48\u5b83\u53ef\u4ee5\u8f6c\u6362\u4e3a\u6574\u65701\u30012\u30014\u548c8\u3002<\/p>\n

\u4e8c\u3001\u539f\u7406<\/h2>\n

  i\u4e00\u4e2a\u5b57\u8282\u8f6cint\u7684\u539f\u7406\u662f\u5c06\u4e00\u4e2a\u5b57\u8282\u7684\u4e8c\u8fdb\u5236\u6570\u636e\u5206\u89e3\u4e3a8\u4e2a\u4f4d\uff0c\u5e76\u5c06\u6bcf\u4e00\u4f4d\u8f6c\u6362\u4e3a\u4e00\u4e2a\u6574\u6570\u3002\u5b83\u7684\u5b9e\u73b0\u539f\u7406\u662f\u5c06\u4e8c\u8fdb\u5236\u6570\u636e\u7684\u6bcf\u4e00\u4f4d\u4e0e2\u7684\u6b21\u5e42\u76f8\u4e58\uff0c\u7136\u540e\u5c06\u7ed3\u679c\u76f8\u52a0\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4e00\u4e2a\u5b57\u8282\u7684\u4e8c\u8fdb\u5236\u6570\u636e\u4e3a00000101\uff0c\u90a3\u4e48\u5b83\u53ef\u4ee5\u8f6c\u6362\u4e3a\u6574\u65701\u30012\u30014\u548c8\uff0c\u56e0\u4e3a00000101 = 1 * 2^0 + 0 * 2^1 + 0 * 2^2 + 0 * 2^3 + 1 * 2^4 + 0 * 2^5 + 0 * 2^6 + 1 * 2^7 = 1 + 8 = 9\u3002<\/p>\n

\u4e09\u3001\u5e94\u7528<\/h2>\n

  i\u4e00\u4e2a\u5b57\u8282\u8f6cint\u6280\u672f\u5728\u8ba1\u7b97\u673a\u7f16\u7a0b\u4e2d\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u5b83\u53ef\u4ee5\u5c06\u5b57\u8282\u6d41\u8f6c\u6362\u4e3a\u53ef\u8bfb\u7684\u6574\u6570\u5f62\u5f0f\uff0c\u4ece\u800c\u5b9e\u73b0\u66f4\u7cbe\u786e\u7684\u6570\u636e\u64cd\u4f5c\u3002\u6bd4\u5982\uff0c\u5b83\u53ef\u4ee5\u7528\u4e8e\u5b57\u8282\u6d41\u7684\u538b\u7f29\u3001\u52a0\u5bc6\u548c\u89e3\u5bc6\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u56fe\u50cf\u3001\u89c6\u9891\u548c\u97f3\u9891\u7684\u7f16\u7801\u548c\u89e3\u7801\u3002\u6b64\u5916\uff0c\u5b83\u8fd8\u53ef\u4ee5\u7528\u4e8e\u7f51\u7edc\u4f20\u8f93\u4e2d\u7684\u6570\u636e\u683c\u5f0f\u8f6c\u6362\uff0c\u4ee5\u53ca\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u5b58\u50a8\u548c\u68c0\u7d22\u3002<\/p>\n

\u56db\u3001\u5b9e\u73b0\u65b9\u6cd5<\/h2>\n

  1.\u4f7f\u7528\u4f4d\u8fd0\u7b97\u5b9e\u73b0<\/h3>\n

  \u4f7f\u7528\u4f4d\u8fd0\u7b97\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5b9e\u73b0i\u4e00\u4e2a\u5b57\u8282\u8f6cint\uff0c\u53ea\u9700\u8981\u5c06\u4e8c\u8fdb\u5236\u6570\u636e\u7684\u6bcf\u4e00\u4f4d\u4e0e2\u7684\u6b21\u5e42\u76f8\u4e58\uff0c\u7136\u540e\u5c06\u7ed3\u679c\u76f8\u52a0\u5373\u53ef\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4e00\u4e2a\u5b57\u8282\u7684\u4e8c\u8fdb\u5236\u6570\u636e\u4e3a00000101\uff0c\u90a3\u4e48\u5b83\u53ef\u4ee5\u4f7f\u7528\u4f4d\u8fd0\u7b97\u8f6c\u6362\u4e3a\u6574\u65709\uff0c\u56e0\u4e3a00000101 = 1 * 2^0 + 0 * 2^1 + 0 * 2^2 + 0 * 2^3 + 1 * 2^4 + 0 * 2^5 + 0 * 2^6 + 1 * 2^7 = 1 + 8 = 9\u3002<\/p>\n

  2.\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u5b9e\u73b0<\/h3>\n

  \u5927\u591a\u6570\u7f16\u7a0b\u8bed\u8a00\u90fd\u63d0\u4f9b\u4e86\u5185\u7f6e\u51fd\u6570\u6765\u5b9e\u73b0i\u4e00\u4e2a\u5b57\u8282\u8f6cint\uff0c\u6bd4\u5982Java\u4e2d\u7684Byte.toInt()\u51fd\u6570\uff0cC++\u4e2d\u7684BYTE_TO_INT()\u51fd\u6570\uff0cPython\u4e2d\u7684int.from_bytes()\u51fd\u6570\u7b49\u7b49\u3002\u4f7f\u7528\u8fd9\u4e9b\u5185\u7f6e\u51fd\u6570\u53ef\u4ee5\u8282\u7701\u5927\u91cf\u7684\u65f6\u95f4\u548c\u7cbe\u529b\uff0c\u4ece\u800c\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u3002<\/p>\n

\u603b\u7ed3<\/h2>\n

  \u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86i\u4e00\u4e2a\u5b57\u8282\u8f6cint\u7684\u539f\u7406\u3001\u5e94\u7528\u548c\u5b9e\u73b0\u65b9\u6cd5\u3002<\/strong>\u5b83\u662f\u4e00\u79cd\u6570\u636e\u8f6c\u6362\u6280\u672f\uff0c\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5b57\u8282\u7684\u6570\u636e\u8f6c\u6362\u4e3a\u4e00\u4e2a\u6574\u6570\uff0c\u4ece\u800c\u5b9e\u73b0\u66f4\u7cbe\u786e\u7684\u6570\u636e\u64cd\u4f5c\u3002\u5b83\u5728\u8ba1\u7b97\u673a\u7f16\u7a0b\u4e2d\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u53ef\u4ee5\u7528\u4e8e\u5b57\u8282\u6d41\u7684\u538b\u7f29\u3001\u52a0\u5bc6\u548c\u89e3\u5bc6\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u56fe\u50cf\u3001\u89c6\u9891\u548c\u97f3\u9891\u7684\u7f16\u7801\u548c\u89e3\u7801\u3002\u6b64\u5916\uff0c\u5b83\u8fd8\u53ef\u4ee5\u7528\u4e8e\u7f51\u7edc\u4f20\u8f93\u4e2d\u7684\u6570\u636e\u683c\u5f0f\u8f6c\u6362\uff0c\u4ee5\u53ca\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u5b58\u50a8\u548c\u68c0\u7d22\u3002i\u4e00\u4e2a\u5b57\u8282\u8f6cint\u7684\u5b9e\u73b0\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a\u4f7f\u7528\u4f4d\u8fd0\u7b97\u548c\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

i\u4e00\u4e2a\u5b57\u8282\u8f6cint\uff08\u53c8\u79f0\u4e3a\u5b57\u8282\u8f6c\u6362\uff09\u662f\u4e00\u79cd\u5e38\u7528\u7684\u6570\u636e\u8f6c\u6362\u6280\u672f\uff0c\u5b83\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5b57\u8282\u7684\u6570\u636e\u8f6c\u6362\u4e3a\u4e00\u4e2a\u6574\u6570\u3002\u8fd9\u79cd\u6280\u672f\u5728\u8ba1\u7b97\u673a\u7f16\u7a0b\u4e2d\u975e\u5e38\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5c06\u5b57\u8282\u6d41\u8f6c\u6362\u4e3a\u53ef\u8bfb\u7684\u6574\u6570\u5f62\u5f0f<\/p>\n","protected":false},"author":1,"featured_media":4132,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[305],"class_list":["post-40169","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-dzjs"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/40169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=40169"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/40169\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/4132"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=40169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=40169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=40169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}