{"id":175186,"date":"2020-04-09T09:27:30","date_gmt":"2020-04-09T01:27:30","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=175186"},"modified":"2020-03-24T12:27:58","modified_gmt":"2020-03-24T04:27:58","slug":"swift-literally-explain","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/swift-literally-explain.html","title":{"rendered":"Swift \u5b57\u9762\u91cf\u8bb2\u89e3"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nSwift \u662f\u4e00\u79cd\u652f\u6301\u591a\u7f16\u7a0b\u8303\u5f0f\u548c\u7f16\u8bd1\u5f0f\u7684\u5f00\u6e90\u7f16\u7a0b\u8bed\u8a00,\u82f9\u679c\u4e8e2014\u5e74WWDC\uff08\u82f9\u679c\u5f00\u53d1\u8005\u5927\u4f1a\uff09\u53d1\u5e03\uff0c\u7528\u4e8e\u5f00\u53d1 iOS\uff0cOS X \u548c watchOS \u5e94\u7528\u7a0b\u5e8f\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"
\n\u6240\u8c13\u5b57\u9762\u91cf\uff0c\u5c31\u662f\u6307\u50cf\u7279\u5b9a\u7684\u6570\u5b57\uff0c\u5b57\u7b26\u4e32\u6216\u8005\u662f\u5e03\u5c14\u503c\u8fd9\u6837\uff0c\u80fd\u591f\u76f4\u63a5\u4e86\u5f53\u5730\u6307\u51fa\u81ea\u5df1\u7684\u7c7b\u578b\u5e76\u4e3a\u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u7684\u503c\u3002\u6bd4\u5982\u5728\u4e0b\u9762\uff1a<\/p>\n

\r\nlet aNumber = 3         \/\/\u6574\u578b\u5b57\u9762\u91cf\r\nlet aString = \"Hello\"   \/\/\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\r\nlet aBool = true        \/\/\u5e03\u5c14\u503c\u5b57\u9762\u91cf\r\n<\/pre>\n
\u6574\u578b\u5b57\u9762\u91cf<\/strong><\/div>\n

\u6574\u578b\u5b57\u9762\u91cf\u53ef\u4ee5\u662f\u4e00\u4e2a\u5341\u8fdb\u5236\uff0c\u4e8c\u8fdb\u5236\uff0c\u516b\u8fdb\u5236\u6216\u5341\u516d\u8fdb\u5236\u5e38\u91cf\u3002 \u4e8c\u8fdb\u5236\u524d\u7f00\u4e3a 0b\uff0c\u516b\u8fdb\u5236\u524d\u7f00\u4e3a 0o\uff0c\u5341\u516d\u8fdb\u5236\u524d\u7f00\u4e3a 0x\uff0c\u5341\u8fdb\u5236\u6ca1\u6709\u524d\u7f00\uff1a<\/p>\n

\u4ee5\u4e0b\u4e3a\u4e00\u4e9b\u6574\u578b\u5b57\u9762\u91cf\u7684\u5b9e\u4f8b\uff1a<\/p>\n

\r\nlet decimalInteger = 17           \/\/ 17 - \u5341\u8fdb\u5236\u8868\u793a\r\nlet binaryInteger = 0b10001       \/\/ 17 - \u4e8c\u8fdb\u5236\u8868\u793a\r\nlet octalInteger = 0o21           \/\/ 17 - \u516b\u8fdb\u5236\u8868\u793a\r\nlet hexadecimalInteger = 0x11     \/\/ 17 - \u5341\u516d\u8fdb\u5236\u8868\u793a\r\n<\/pre>\n
\u6d6e\u70b9\u578b\u5b57\u9762\u91cf<\/strong><\/div>\n

\u6d6e\u70b9\u578b\u5b57\u9762\u91cf\u6709\u6574\u6570\u90e8\u5206\uff0c\u5c0f\u6570\u70b9\uff0c\u5c0f\u6570\u90e8\u5206\u53ca\u6307\u6570\u90e8\u5206\u3002<\/p>\n

\u9664\u975e\u7279\u522b\u6307\u5b9a\uff0c\u6d6e\u70b9\u578b\u5b57\u9762\u91cf\u7684\u9ed8\u8ba4\u63a8\u5bfc\u7c7b\u578b\u4e3a Swift \u6807\u51c6\u5e93\u7c7b\u578b\u4e2d\u7684 Double\uff0c\u8868\u793a64\u4f4d\u6d6e\u70b9\u6570\u3002<\/p>\n

\u6d6e\u70b9\u578b\u5b57\u9762\u91cf\u9ed8\u8ba4\u7528\u5341\u8fdb\u5236\u8868\u793a\uff08\u65e0\u524d\u7f00\uff09\uff0c\u4e5f\u53ef\u4ee5\u7528\u5341\u516d\u8fdb\u5236\u8868\u793a\uff08\u52a0\u524d\u7f00 0x\uff09\u3002<\/p>\n

\u5341\u8fdb\u5236\u6d6e\u70b9\u578b\u5b57\u9762\u91cf\u7531\u5341\u8fdb\u5236\u6570\u5b57\u4e32\u540e\u8ddf\u5c0f\u6570\u90e8\u5206\u6216\u6307\u6570\u90e8\u5206\uff08\u6216\u4e24\u8005\u7686\u6709\uff09\u7ec4\u6210\u3002\u5341\u8fdb\u5236\u5c0f\u6570\u90e8\u5206\u7531\u5c0f\u6570\u70b9 . \u540e\u8ddf\u5341\u8fdb\u5236\u6570\u5b57\u4e32\u7ec4\u6210\u3002\u6307\u6570\u90e8\u5206\u7531\u5927\u5199\u6216\u5c0f\u5199\u5b57\u6bcd e \u4e3a\u524d\u7f00\u540e\u8ddf\u5341\u8fdb\u5236\u6570\u5b57\u4e32\u7ec4\u6210\uff0c\u8fd9\u4e32\u6570\u5b57\u8868\u793a e \u4e4b\u524d\u7684\u6570\u91cf\u4e58\u4ee5 10 \u7684\u51e0\u6b21\u65b9\u3002\u4f8b\u5982\uff1a1.25e2 \u8868\u793a 1.25 \u2a09 10^2\uff0c\u4e5f\u5c31\u662f 125.0\uff1b\u540c\u6837\uff0c1.25e\uff0d2 \u8868\u793a 1.25 \u2a09 10^\uff0d2\uff0c\u4e5f\u5c31\u662f 0.0125\u3002<\/p>\n

\u5341\u516d\u8fdb\u5236\u6d6e\u70b9\u578b\u5b57\u9762\u91cf\u7531\u524d\u7f00 0x \u540e\u8ddf\u53ef\u9009\u7684\u5341\u516d\u8fdb\u5236\u5c0f\u6570\u90e8\u5206\u4ee5\u53ca\u5341\u516d\u8fdb\u5236\u6307\u6570\u90e8\u5206\u7ec4\u6210\u3002\u5341\u516d\u8fdb\u5236\u5c0f\u6570\u90e8\u5206\u7531\u5c0f\u6570\u70b9\u540e\u8ddf\u5341\u516d\u8fdb\u5236\u6570\u5b57\u4e32\u7ec4\u6210\u3002\u6307\u6570\u90e8\u5206\u7531\u5927\u5199\u6216\u5c0f\u5199\u5b57\u6bcd p \u4e3a\u524d\u7f00\u540e\u8ddf\u5341\u8fdb\u5236\u6570\u5b57\u4e32\u7ec4\u6210\uff0c\u8fd9\u4e32\u6570\u5b57\u8868\u793a p \u4e4b\u524d\u7684\u6570\u91cf\u4e58\u4ee5 2 \u7684\u51e0\u6b21\u65b9\u3002\u4f8b\u5982\uff1a0xFp2 \u8868\u793a 15 \u2a09 2^2\uff0c\u4e5f\u5c31\u662f 60\uff1b\u540c\u6837\uff0c0xFp-2 \u8868\u793a 15 \u2a09 2^-2\uff0c\u4e5f\u5c31\u662f 3.75\u3002<\/p>\n

\u8d1f\u7684\u6d6e\u70b9\u578b\u5b57\u9762\u91cf\u7531\u4e00\u5143\u8fd0\u7b97\u7b26\u51cf\u53f7 - \u548c\u6d6e\u70b9\u578b\u5b57\u9762\u91cf\u7ec4\u6210\uff0c\u4f8b\u5982 -42.5\u3002<\/p>\n

\u6d6e\u70b9\u578b\u5b57\u9762\u91cf\u5141\u8bb8\u4f7f\u7528\u4e0b\u5212\u7ebf _ \u6765\u589e\u5f3a\u6570\u5b57\u7684\u53ef\u8bfb\u6027\uff0c\u4e0b\u5212\u7ebf\u4f1a\u88ab\u7cfb\u7edf\u5ffd\u7565\uff0c\u56e0\u6b64\u4e0d\u4f1a\u5f71\u54cd\u5b57\u9762\u91cf\u7684\u503c\u3002\u540c\u6837\u5730\uff0c\u4e5f\u53ef\u4ee5\u5728\u6570\u5b57\u524d\u52a0 0\uff0c\u5e76\u4e0d\u4f1a\u5f71\u54cd\u5b57\u9762\u91cf\u7684\u503c\u3002<\/p>\n

\u4ee5\u4e0b\u4e3a\u4e00\u4e9b\u6d6e\u70b9\u578b\u5b57\u9762\u91cf\u7684\u5b9e\u4f8b\uff1a<\/p>\n

\r\nlet decimalDouble = 12.1875       \/\/\u5341\u8fdb\u5236\u6d6e\u70b9\u578b\u5b57\u9762\u91cf\r\nlet exponentDouble = 1.21875e1    \/\/\u5341\u8fdb\u5236\u6d6e\u70b9\u578b\u5b57\u9762\u91cf\r\nlet hexadecimalDouble = 0xC.3p0   \/\/\u5341\u516d\u8fdb\u5236\u6d6e\u70b9\u578b\u5b57\u9762\u91cf\r\n<\/pre>\n
\u5b57\u7b26\u4e32\u578b\u5b57\u9762\u91cf<\/strong><\/div>\n

\u5b57\u7b26\u4e32\u578b\u5b57\u9762\u91cf\u7531\u88ab\u5305\u5728\u53cc\u5f15\u53f7\u4e2d\u7684\u4e00\u4e32\u5b57\u7b26\u7ec4\u6210\uff0c\u5f62\u5f0f\u5982\u4e0b\uff1a<\/p>\n

\r\n\"characters\"<\/pre>\n

\u5b57\u7b26\u4e32\u578b\u5b57\u9762\u91cf\u4e2d\u4e0d\u80fd\u5305\u542b\u672a\u8f6c\u4e49\u7684\u53cc\u5f15\u53f7 \uff08\"\uff09\u3001\u672a\u8f6c\u4e49\u7684\u53cd\u659c\u7ebf\uff08\\\uff09\u3001\u56de\u8f66\u7b26\u6216\u6362\u884c\u7b26\u3002
\n\"\"
\n\u4ee5\u4e0b\u4e3a\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u7684\u7b80\u5355\u5b9e\u4f8b\uff1a<\/p>\n

\r\nimport Cocoa\r\n\r\nlet stringL = \"Hello\\tWorld\\n\\nLinux\u5c31\u8be5\u8fd9\u4e48\u5b66\u5b98\u7f51\uff1a\\'http:\/\/lrxjmw.cn\\'\"\r\nprint(stringL)<\/pre>\n

\u4ee5\u4e0a\u7a0b\u5e8f\u6267\u884c\u7ed3\u679c\u4e3a\uff1a<\/p>\n

\r\nHello    World\r\n<\/pre>\n

Linux\u5c31\u8be5\u8fd9\u4e48\u5b66\u5b98\u7f51\uff1a'http:\/\/lrxjmw.cn'<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6240\u8c13\u5b57\u9762\u91cf\uff0c\u5c31\u662f\u6307\u50cf\u7279\u5b9a\u7684\u6570\u5b57\uff0c\u5b57\u7b26\u4e32\u6216\u8005\u662f\u5e03\u5c14\u503c\u8fd9\u6837\uff0c\u80fd\u591f\u76f4\u63a5\u4e86\u5f53\u5730\u6307\u51fa\u81ea\u5df1\u7684\u7c7b\u578b\u5e76\u4e3a\u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u7684\u503c\u3002\u6bd4\u5982 […]<\/p>\n","protected":false},"author":1470,"featured_media":175141,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-175186","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/175186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1470"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=175186"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/175186\/revisions"}],"predecessor-version":[{"id":175196,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/175186\/revisions\/175196"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/175141"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=175186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=175186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=175186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}