透過集合功能整理內容
你可以依據偏好儲存及分類內容。
math.random
math.random()
說明
產生 [0, 1)
範圍內的 DOUBLE 型虛擬隨機值,包含 0 但不含 1。
傳回類型
FLOAT
程式碼範例
以下範例會檢查隨機值是否在 [0, 1)
範圍內。none
if(math.random() >= 0 and math.random() < 1) = true
除非另有註明,否則本頁面中的內容是採用創用 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.random()\u003c/code\u003e generates a pseudo-random floating-point number.\u003c/p\u003e\n"],["\u003cp\u003eThe generated value from \u003ccode\u003emath.random()\u003c/code\u003e falls within the range of 0 (inclusive) up to, but not including, 1.\u003c/p\u003e\n"],["\u003cp\u003eThis function is supported in Rules and Search environments within the context of the documentation.\u003c/p\u003e\n"],["\u003cp\u003eThe return type of the function is \u003ccode\u003eFLOAT\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["### math.random\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n math.random()\n\n#### Description\n\nGenerates a pseudo-random value of type DOUBLE in the range of `[0, 1)`, inclusive of 0 and exclusive of 1.\n\n#### Return type\n\n`FLOAT`\n\n#### Code samples\n\nThe following example checks whether the random value is in the range `[0, 1)`.\n`none\nif(math.random() \u003e= 0 and math.random() \u003c 1) = true`"]]