Decimal
- Last Updated: December 12, 2022
- 1 minute read
- Corticon.js
- Documentation
In this section, wherever the syntax includes <Number>, either Integer or Decimal data types may be used.
Corticon.js's Decimal attribute operators are as follows:
| Name and Syntax | Returns | Description | |
|---|---|---|---|
| Equals (used as a comparison) | |||
<Number1> =
<Number2> |
Boolean | Returns a value of true if <Number1> is the same as <Number2>. |
|
| Equals (used as an assignment) | |||
<Number1> =
<Number2> |
Number | Assigns the value of <Number2> to the value of <Number1>. |
|
| Not Equal To | |||
<Number1> <>
<Number2> |
Boolean | Returns a value of true if <Number1> is not equal to <Number2>. |
|
| Less than | |||
<Number1> <
<Number2> |
Boolean | Returns a value of true if <Number1> is less than <Number2>. |
|
| Greater than | |||
<Number1> >
<Number2> |
Boolean | Returns a value of true if <Number1> is greater than <Number2>. |
|
| Less than or Equal to | |||
<Number1> <=
<Number2> |
Boolean | Returns a value of true if <Number1> is less than or equal to <Number2>. |
|
| Greater than or Equal to | |||
<Number1> >=
<Number2> |
Boolean | Returns a value of true if <Number1> is greater than or equal to <Number2>. |
|
| In (Range) | |||
attributeReference in
[ |(rangeExpression)|]
|
Boolean | Returns a value of true if attributeReference is in the range of Decimal values from..to, and where
opening and closing parentheses ( )indicate
exclusion of that limit and square brackets [
] indicate inclusion of that limit. |
|
| In (List) | |||
attributeReference in
{listExpression} |
Boolean | Returns a value of true if attributeReference is in the comma-delimited list of literal
values, defined enumeration values, or - if in use - enumeration labels.
|
|
| Add | |||
<Number1> +
<Number2> |
Number | Returns the sum of <Number1> and <Number2>.
The resulting data type is the more expansive of either <Number1> or <Number2>. For example, if an Integer value is added to a
Decimal value, the resulting value will be a Decimal. See Precedence of rule operators. |
|
| Subtract | |||
<Number1> -
<Number2> |
Number | Subtracts <Number2>
from <Number1>. The resulting data type
is the more expansive of either <Number1> or <Number2>. See
Precedence of rule operators.
|
|
| Multiply | |||
<Number1> *
<Number2> |
Number | Returns the product of <Number1> and <Number2>. The resulting data type is the more expansive of either
<Number1> or <Number2>. See Precedence of rule operators. |
|
| Divide | |||
<Number1> /
<Number2> |
Number | Divides <Number1>
by <Number2>. The resulting data type
is the more expansive of either <Number1> or <Number2>. See
Precedence of rule operators.
|
|
| Exponent | |||
<Number1> **
<Number2> |
Number | Raises <Number1>
to the power of <Number2>. The
resulting data type is the more expansive of either <Number1> or <Number2>. See Precedence of rule operators. |
|
| Absolute Value | |||
<Decimal>.absVal |
Decimal | Returns the absolute value of <Number>. If the <Number> is positive, <Number> itself is returned; if <Number> is negative, the negation of <Number> is returned. |
|
| Floor | |||
<Decimal>.floor |
Integer | Returns a new Decimal whose value is the value of this Decimal rounded to a whole number in the direction of negative infinity. | |
| Ceiling | |||
<Decimal>.ceiling |
Integer | Returns a new Decimal whose value is the value of this Decimal rounded to a whole number in the direction of positive infinity. | |
| Round | |||
<Decimal>.round |
Decimal | Rounds <Decimal>
to the nearest Integer. |
|
| Round(n) | |||
<Decimal>.round(<decimalDigits<Integer>>) |
Decimal | Returns <Decimal>
rounded to the number of decimal places specified by decimalDigits. Rounds toward the nearest neighbor; where
equivalent, rounds toward infinity. |
|
| Round(n) | |||
<Decimal>.round(<decimalDigits<Integer>>,mode:<integer) |
Decimal | Returns <Decimal>
rounded to the number of decimal places specified by decimalDigits. See details page for information about
mode. |
|
| Maximum Value | |||
<Decimal>.max(<Number>) |
Number | Returns the greater of <Decimal> and <Number>. |
|
| Minimum Value | |||
<Decimal>.min(<Number>) |
Number | Returns the lesser of <Decimal> and <Number>. |
|
| Logarithm (base 10) | |||
<Decimal>.log |
Decimal | Returns the logarithm (base 10) of <Decimal>. <Decimal> may not be zero. |
|
| Logarithm (base x) | |||
<Decimal1>.log(<Decimal2>) |
Decimal | Returns the logarithm (base <Decimal2>) of <Decimal1>. <Decimal1>
may not be zero. |
|
| Natural Logarithm | |||
<Decimal>.ln |
Decimal | Returns the logarithm (base e) of <Decimal>.<Decimal> may not be zero. |
|
| Random | |||
<Decimal>.random(minRange,
maxRange) |
Decimal | Returns a random decimal between minRange and maxRange. |
|
| Truncate | |||
<Decimal>.truncate |
Integer | Truncates "this" Decimal value to an integer by removing the fractional portion. | |