Swift \u6709 sqrt \u51fd\u6570\u3002sqrt \u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e00\u4e2a\u6570\u7684\u5e73\u65b9\u6839\u3002\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a\n\nswift\nimport Foundation\n\nlet number = 16.0\nlet squareRoot = sqrt(number)\nprint(squareRoot) // \u8f93\u51fa\uff1a4.0\n\n\n\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0csqrt \u51fd\u6570\u5728 Swift \u4e2d\u662f\u5b9a\u4e49\u5728 Foundation \u6846\u67b6\u4e2d\u7684\uff0c\u6240\u4ee5\u5728\u4f7f\u7528\u524d\u9700\u8981\u5148\u5bfc\u5165 Foundation \u5e93\u3002\u53e6\u5916\uff0csqrt \u51fd\u6570\u7684\u53c2\u6570\u7c7b\u578b\u662f Double\uff0c\u6240\u4ee5\u9700\u8981\u8f93\u5165\u4e00\u4e2a Double \u7c7b\u578b\u7684\u6570\u503c\u4f5c\u4e3a\u53c2\u6570\u3002

Swift sqrt函数:计算平方根

原文地址: https://www.cveoy.top/t/topic/pZut 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录