數學函式 math-functions
數學函式為歷程運算式中的數值計算提供基本的數學運算。 這些函式可讓您對資料執行精確數值計算和轉換。
當您需要以下作業時使用數學函式:
數學函式會處理十進位和整數型別,並自動管理型別轉換,以確保歷程運算式中的結果準確。
random random
產生介於0和1之間的隨機數字。
語法
random()簽章與傳回的型別
random()
傳回小數。
round round
傳回引數最接近的整數值,並會將四捨五入連結至正無限。
語法
round(<parameters>)參數
- 小數
- 整數
簽章與傳回型別
round(<decimal>)
round(<integer>)
傳回整數。
範例
round(3.14)
傳回3。
round(3.54)
傳回4。
round(-3.14)
傳回–3。
round(3)
傳回3。
AI Knowledge Reference
This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.
For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.
- TL;DR: This page documents the two math functions available in AJO journey expressions —
randomfor generating a random decimal between 0 and 1, androundfor rounding a decimal or integer to the nearest integer.
Intents:
- Generate a random decimal value between 0 and 1 for sampling or randomization logic using
random - Round a decimal number to the nearest integer using
round - Apply rounding in business logic where whole numbers are required from decimal calculations
Glossary:
- random: A function that returns a pseudo-random decimal value from 0 (inclusive) to 1 (exclusive) (product-specific)
- round: A function that returns the closest integer to the input, with half-values rounding toward positive infinity
Guardrails:
random()takes no parametersroundaccepts decimal or integer input and always returns an integer- Ties in
roundare resolved by rounding toward positive infinity (e.g., 3.5 rounds to 4, -3.5 rounds to -3)
Terminology:
- Canonical name: Math functions — Acronym: none — variants: mathematical functions, numeric functions
- Synonyms: “round” = “round to nearest integer”
- Do not confuse: “round” (rounds to the nearest integer) ≠ conversion functions like
toInteger(truncates the decimal part without rounding)
FAQ:
- Q: What does
random()return? — It returns a random decimal number between 0 and 1. - Q: How does
roundhandle negative numbers? — It rounds toward positive infinity, soround(-3.14)returns -3 andround(-3.54)returns -3 as well (closest integer toward positive infinity). - Q: What is the difference between
roundandtoInteger? —roundrounds to the nearest integer (3.7 becomes 4), whiletoIntegertruncates the decimal part without rounding (3.7 becomes 3). - Q: Does
randomtake any parameters? — No,random()requires no parameters and always returns a decimal between 0 and 1.
recommendation-more-help
journey-optimizer-help