使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
math.random
math.random()
说明
在范围 [0, 1)
(包含 0,不包含 1)内生成 DOUBLE 类型的伪随机值。
返回类型
FLOAT
代码示例
以下示例检查随机值是否在 [0, 1)
范围内。none
if(math.random() >= 0 and math.random() < 1) = true
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):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"]],["最后更新时间 (UTC):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`"]]