-
Notifications
You must be signed in to change notification settings - Fork 0
API Round en
ClassicUO / Basic IDE
Rounds a calculated value to a chosen number of decimal places, for example a displayed resource percentage.
Round(number:Any, digits:Any) -> Decimal
Round(value:Any) -> Any
-
value— One required Integer/Decimal or numeric String. Text uses a dot and optional exponent, independent of UI language; "0x0EED" is not numeric text here. Invalid text, Array, Object and Unit become 0. Validate user input with IsNumeric before converting. -
number— One required Integer/Decimal or numeric String. Text uses a dot and optional exponent, independent of UI language; "0x0EED" is not numeric text here. Invalid text, Array, Object and Unit become 0. Validate user input with IsNumeric before converting. -
digits— Optional Integer decimal-place count; omitted means 0. Values below 0 are clamped to 0 and values above 15 to 15. This argument does not select rounding to tens or hundreds.
Decimal, using midpoint-to-even rounding: Round(2.5) is 2 and Round(3.5) is 4. Unlike CInt/CLng, exact halves are not rounded away from zero. Binary floating-point representation can affect apparent decimal ties; the result is a number, not fixed-width formatted text.
- One required Integer/Decimal or numeric String. Text uses a dot and optional exponent, independent of UI language; "0x0EED" is not numeric text here. Invalid text, Array, Object and Unit become 0. Validate user input with IsNumeric before converting.
- Decimal, using midpoint-to-even rounding: Round(2.5) is 2 and Round(3.5) is 4. Unlike CInt/CLng, exact halves are not rounded away from zero. Binary floating-point representation can affect apparent decimal ties; the result is a number, not fixed-width formatted text.
Rounds a calculated value to a chosen number of decimal places, for example a displayed resource percentage.
One required Integer/Decimal or numeric String. Text uses a dot and optional exponent, independent of UI language; "0x0EED" is not numeric text here. Invalid text, Array, Object and Unit become 0. Validate user input with IsNumeric before converting.
Decimal, using midpoint-to-even rounding: Round(2.5) is 2 and Round(3.5) is 4. Unlike CInt/CLng, exact halves are not rounded away from zero. Binary floating-point representation can affect apparent decimal ties; the result is a number, not fixed-width formatted text.
Project source: external/InjectionScript/src/InjectionScript/Runtime/InjectionApi.cs; function BasicRound.
# Round — 1
#
# Rounds a calculated value to a chosen number of decimal places, for example a displayed
# resource percentage.
#
# Decimal, using midpoint-to-even rounding: Round(2.5) is 2 and Round(3.5) is 4. Unlike
# CInt/CLng, exact halves are not rounded away from zero. Binary floating-point representation
# can affect apparent decimal ties; the result is a number, not fixed-width formatted text.
SUB Main()
# With one argument, Round(2.5) rounds to zero decimal places and returns Decimal 2. CInt(2.5)
# would return Integer 3 in this engine.
RETURN Round(2.5)
END SUBParameter and execution notes:
- With one argument, Round(2.5) rounds to zero decimal places and returns Decimal 2. CInt(2.5) would return Integer 3 in this engine.
# Round — 2
#
# Rounds a calculated value to a chosen number of decimal places, for example a displayed
# resource percentage.
#
# Decimal, using midpoint-to-even rounding: Round(2.5) is 2 and Round(3.5) is 4. Unlike
# CInt/CLng, exact halves are not rounded away from zero. Binary floating-point representation
# can affect apparent decimal ties; the result is a number, not fixed-width formatted text.
SUB Main()
# number=12.375, digits=2 gives Decimal 12.38. digits describes decimal places, not significant
# digits.
RETURN Round(12.375,2)
END SUBParameter and execution notes:
- number=12.375, digits=2 gives Decimal 12.38. digits describes decimal places, not significant digits.
# Round — 3
#
# Rounds a calculated value to a chosen number of decimal places, for example a displayed
# resource percentage.
#
# Decimal, using midpoint-to-even rounding: Round(2.5) is 2 and Round(3.5) is 4. Unlike
# CInt/CLng, exact halves are not rounded away from zero. Binary floating-point representation
# can affect apparent decimal ties; the result is a number, not fixed-width formatted text.
SUB Main()
# Percent receives current=37, maximum=80, computes 46.25 and rounds to one decimal place:
# Decimal 46.2. A nonpositive maximum returns -1 instead of dividing by zero. Supply already
# validated finite resource values.
RETURN Percent(37,80)
END SUB
SUB Percent(current,maximum)
IF maximum <= 0 THEN
RETURN -1
END IF
RETURN Round(CDbl(current) * 100 / maximum,1)
END SUBParameter and execution notes:
- Percent receives current=37, maximum=80, computes 46.25 and rounds to one decimal place: Decimal 46.2. A nonpositive maximum returns -1 instead of dividing by zero. Supply already validated finite resource values.
Русский · English · Українська · Français · Deutsch · Italiano · Español · 繁體中文 · 日本語 · 한국어
ClassicUO
Bad Newbie & Basic IDE
Найти в справочнике
Клиент и скрипты
Каталоги значений
Разработка и помощь