透過集合功能整理內容
你可以依據偏好儲存及分類內容。
math.sqrt
math.sqrt(number)
說明
傳回指定數字的平方根。如果數字為負數,則傳回 0。
參數資料類型
INT|FLOAT
傳回類型
FLOAT
程式碼範例
範例 1
這個範例會傳回 int 引數的平方根。
math.sqrt(3) = 1.732051
範例 2
這個範例會傳回負數 int 引數的平方根。
math.sqrt(-3) = 0.000000
範例 3
這個範例會傳回零引數的平方根。
math.sqrt(0) = 0.000000
範例 4
這個範例會傳回浮點引數的平方根。
math.sqrt(9.223372) = 3.037000
範例 5
這個範例會傳回負浮點引數的平方根。
math.sqrt(0-1.200000) = 0.000000
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-29 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-29 (世界標準時間)。"],[[["\u003cp\u003e\u003ccode\u003emath.sqrt\u003c/code\u003e calculates the square root of a given number, supporting both \u003ccode\u003eINT\u003c/code\u003e and \u003ccode\u003eFLOAT\u003c/code\u003e data types.\u003c/p\u003e\n"],["\u003cp\u003eThe function returns a \u003ccode\u003eFLOAT\u003c/code\u003e value representing the square root.\u003c/p\u003e\n"],["\u003cp\u003eIf a negative number is provided as input, \u003ccode\u003emath.sqrt\u003c/code\u003e will return 0.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003emath.sqrt\u003c/code\u003e function is supported in \u003ca href=\"/chronicle/docs/detection/default-rules\"\u003eRules\u003c/a\u003e and \u003ca href=\"/chronicle/docs/investigation/udm-search\"\u003eSearch\u003c/a\u003e.\u003c/p\u003e\n"]]],[],null,["### math.sqrt\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n math.sqrt(number)\n\n#### Description\n\nReturns the square root of the given number. Returns 0 in case of negative numbers.\n\n#### Param data types\n\n`INT|FLOAT`\n\n#### Return type\n\n`FLOAT`\n\n#### Code samples\n\n##### Example 1\n\nThis example returns the square root of an int argument. \n\n math.sqrt(3) = 1.732051\n\n##### Example 2\n\nThis example returns the square root of a negative int argument. \n\n math.sqrt(-3) = 0.000000\n\n##### Example 3\n\nThis example returns the square root of zero argument. \n\n math.sqrt(0) = 0.000000\n\n##### Example 4\n\nThis example returns the square root of a float argument. \n\n math.sqrt(9.223372) = 3.037000\n\n##### Example 5\n\nThis example returns the square root of a negative float argument. \n\n math.sqrt(0-1.200000) = 0.000000"]]