decimal128

Syntax

decimal128(X, scale)

Arguments

X is an integer/floating-point/string scalar or vector.

scale an integer indicating how many decimal digits fraction can have.

Details

Convert the input values into DECIMAL128.

$ a=decimal128(142, 2)
$ a
142.00

$ b=decimal128(1\7, 6)
$ b
0.142857

$ a+b
142.142857

$ a*b
20.28569400

$ decimal128("3.1415926535", 4)
3.1416

$ // All elements of a DECIMAL vector must be of the same type and scale
$ d1=[1.23$DECIMAL128(4), 3$DECIMAL128(4), 3.14$DECIMAL128(4)];
[1.2300,3.0000,3.1400]
$ typestr(d1)
FAST DECIMAL128 VECTOR

$ // If the elements are of different scales, a tuple is created
$ d2=[1.23$DECIMAL128(4), 3$DECIMAL128(4), 3.14$DECIMAL128(3)];
(1.2300,3.0000,3.140)
$ typestr(d2)
ANY VECTOR