Free cookie consent management tool by TermsFeed

a!toDecimal() Function

On This Page

Converts a value to a Number (Decimal Precise) or Number (Decimal Floating) value.

Parameters

a!toDecimal( value, decimalType )

Keyword Type Description

value

Any Type

Value to convert.

decimalType

Text

Determines the type of the returned value. Valid values are "PRECISE" (default) and "FLOATING".

Returns

The return type of a!toDecimal() depends on the decimalType parameter. Valid return types are:

Using the function

The following sections cover important details about the a!toDecimal() function.

Using the decimalType parameter

The decimalType parameter determines which decimal data type a!toDecimal() returns:

Display values in scientific notation

To display a value in scientific notation, set decimalType to "FLOATING". Numbers less than -10,000,000 and greater than 10,000,000 are represented in scientific notation. Number (Decimal Precise) values do not support scientific notation and instead display the full value.

For example:

1
a!toDecimal(1239329332, "FLOATING")

Returns 1.239329e+09.

1
a!toDecimal(1239329332, "PRECISE")

Returns 1239329332.

Use with arrays

When you pass an array as the value parameter, a!toDecimal() returns an array. Every value in the array is converted to the decimal type specified by the decimalType parameter.

Commas in string values

When a string value contains a comma, a!toDecimal() strips the comma and treats the value as a single number. For example, a!toDecimal("386,255.07") returns 386255.07.

To convert multiple values, pass them as an array. For example, a!toDecimal({"3.6", "4.2"}) returns {3.6, 4.2}.

Examples

The following examples demonstrate the a!toDecimal() function.

To experiment with examples, copy and paste the expression into an expression rule and click TEST RULE to see the output.

Return a precise decimal

1
2
3
4
a!toDecimal(
  value: 3.1111119,
  decimalType: "PRECISE"
)

Returns 3.1111119.

Return a floating decimal

1
2
3
4
a!toDecimal(
  value: 3.1111119,
  decimalType: "FLOATING"
)

Returns 3.111112

Convert a list of floating decimals to precise decimals

This example uses a rule input (ri!rate) to pass in a list of rates from the Exchange Rate record type. This example will error if you try to use it in yours. Use it as a reference only.

By default, the record field rate stores values as Number (Decimal Floating), which rounds the values. This expression converts those values to Number (Decimal Precise):

1
2
3
4
a!toDecimal(
  value: ri!rate[recordType!AT Exchange Rates.fields.rate],
  decimalType: "PRECISE"
)

Returns the following list. The Number (Decimal Precise) values preserve the trailing digits that Number (Decimal Floating) rounds off.

1
2
3
4
5
0.85920437
0.85834219
0.86102345
0.86245678
0.8601239

Feature compatibility

The table below lists this function's compatibility with various features in Appian.
Feature Compatibility Note
Portals Incompatible
Offline Interfaces Compatible
Sync-Time Custom Record Fields Compatible

Can be used to create a custom record field that only evaluates at sync time.

Real-Time Custom Record Fields Incompatible

Custom record fields that evaluate in real time must be configured using one or more Custom Field functions.

Process Reports Compatible
Process Events Compatible

Can be used to configure a process event node, such as a start event or timer event.

Process Autoscaling Compatible

Can be used in autoscaled processes.

Event Consumer Filter Conditions Compatible

Can be used in filter conditions.

Event Consumer Event Handlers Compatible

Can be used in event handler expressions.

Feedback