decimal64

Syntax

decimal64(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 DECIMAL64.

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

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

$ a+b
142.142857

$ a*b
20.28569400

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

$ d2=[1.23$DECIMAL64(4), 3$DECIMAL64(4), 3.14$DECIMAL64(3)];
(1.2300,3.0000,3.140)
$ typestr(d2)
ANY VECTOR

Note: When converting data of STRING/SYMBOL type into DECIMAL, there has been a modification in the way the decimal part exceeding the scale is handled since version 2.00.10.

  • Before version 2.00.10, the decimal part is truncated;

  • Starting from version 2.00.10, the decimal part is rounded.

$ symbol(["1.341", "4.5677"])$DECIMAL64(2)
$ //2.00.10 之前的版本,结果为:
$ [1.34,4.56]
$ //2.00.10 及之后的版本,结果为:
$ [1.34,4.57]