Skip to content

functions_arithmetic_decimal.yaml

This document file is generated for functions_arithmetic_decimal.yaml

Scalar Functions

add

Implementations:
add(x, y, option:overflow): -> return_type
0. add(decimal<P1,S1>, decimal<P2,S2>, option:overflow): ->

init_scale = max(S1,S2)
init_prec = init_scale + max(P1 - S1, P2 - S2) + 1
min_scale = min(init_scale, 6)
delta = init_prec - 38
prec = min(init_prec, 38)
scale_after_borrow = max(init_scale - delta, min_scale)
scale = init_prec > 38 ? scale_after_borrow : init_scale
DECIMAL<prec, scale>  

Add two decimal values.

Options:
  • overflow ['SILENT', 'SATURATE', 'ERROR']
  • subtract

    Implementations:
    subtract(x, y, option:overflow): -> return_type
    0. subtract(decimal<P1,S1>, decimal<P2,S2>, option:overflow): ->

    init_scale = max(S1,S2)
    init_prec = init_scale + max(P1 - S1, P2 - S2) + 1
    min_scale = min(init_scale, 6)
    delta = init_prec - 38
    prec = min(init_prec, 38)
    scale_after_borrow = max(init_scale - delta, min_scale)
    scale = init_prec > 38 ? scale_after_borrow : init_scale
    DECIMAL<prec, scale>  
    

    Options:
  • overflow ['SILENT', 'SATURATE', 'ERROR']
  • multiply

    Implementations:
    multiply(x, y, option:overflow): -> return_type
    0. multiply(decimal<P1,S1>, decimal<P2,S2>, option:overflow): ->

    init_scale = S1 + S2
    init_prec = P1 + P2 + 1
    min_scale = min(init_scale, 6)
    delta = init_prec - 38
    prec = min(init_prec, 38)
    scale_after_borrow = max(init_scale - delta, min_scale)
    scale = init_prec > 38 ? scale_after_borrow : init_scale
    DECIMAL<prec, scale>  
    

    Options:
  • overflow ['SILENT', 'SATURATE', 'ERROR']
  • divide

    Implementations:
    divide(x, y, option:overflow): -> return_type
    0. divide(decimal<P1,S1>, decimal<P2,S2>, option:overflow): ->

    init_scale = max(6, S1 + P2 + 1)
    init_prec = P1 - S1 + P2 + init_scale
    min_scale = min(init_scale, 6)
    delta = init_prec - 38
    prec = min(init_prec, 38)
    scale_after_borrow = max(init_scale - delta, min_scale)
    scale = init_prec > 38 ? scale_after_borrow : init_scale
    DECIMAL<prec, scale>  
    

    Options:
  • overflow ['SILENT', 'SATURATE', 'ERROR']
  • modulus

    Implementations:
    modulus(x, y, option:overflow): -> return_type
    0. modulus(decimal<P1,S1>, decimal<P2,S2>, option:overflow): ->

    init_scale = max(S1,S2)
    init_prec = min(P1 - S1, P2 - S2) + init_scale
    min_scale = min(init_scale, 6)
    delta = init_prec - 38
    prec = min(init_prec, 38)
    scale_after_borrow = max(init_scale - delta, min_scale)
    scale = init_prec > 38 ? scale_after_borrow : init_scale
    DECIMAL<prec, scale>  
    

    Options:
  • overflow ['SILENT', 'SATURATE', 'ERROR']
  • abs

    Implementations:
    abs(x): -> return_type
    0. abs(decimal<P,S>): -> decimal<P,S>

    Calculate the absolute value of the argument.

    bitwise_and

    Implementations:
    bitwise_and(x, y): -> return_type
    0. bitwise_and(DECIMAL<P1,0>, DECIMAL<P2,0>): ->

    max_precision = max(P1, P2)
    DECIMAL<max_precision, 0>  
    

    *Return the bitwise AND result for two decimal inputs. In inputs scale must be 0 (i.e. only integer types are allowed) *

    bitwise_or

    Implementations:
    bitwise_or(x, y): -> return_type
    0. bitwise_or(DECIMAL<P1,0>, DECIMAL<P2,0>): ->

    max_precision = max(P1, P2)
    DECIMAL<max_precision, 0>  
    

    *Return the bitwise OR result for two given decimal inputs. In inputs scale must be 0 (i.e. only integer types are allowed) *

    bitwise_xor

    Implementations:
    bitwise_xor(x, y): -> return_type
    0. bitwise_xor(DECIMAL<P1,0>, DECIMAL<P2,0>): ->

    max_precision = max(P1, P2)
    DECIMAL<max_precision, 0>  
    

    *Return the bitwise XOR result for two given decimal inputs. In inputs scale must be 0 (i.e. only integer types are allowed) *

    sqrt

    Implementations:
    sqrt(x): -> return_type
    0. sqrt(DECIMAL<P,S>): -> fp64

    Square root of the value. Sqrt of 0 is 0 and sqrt of negative values will raise an error.

    factorial

    Implementations:
    factorial(n): -> return_type
    0. factorial(DECIMAL<P,0>): -> DECIMAL<38,0>

    *Return the factorial of a given decimal input. Scale should be 0 for factorial decimal input. The factorial of 0! is 1 by convention. Negative inputs will raise an error. Input which cause overflow of result will raise an error. *

    power

    Implementations:
    power(x, y, option:overflow, option:complex_number_result): -> return_type
    0. power(DECIMAL<P1,S1>, DECIMAL<P2,S2>, option:overflow, option:complex_number_result): -> fp64

    Take the power with x as the base and y as exponent. Behavior for complex number result is indicated by option complex_number_result

    Options:
  • overflow ['SILENT', 'SATURATE', 'ERROR']
  • complex_number_result ['NAN', 'ERROR']
  • Aggregate Functions

    sum

    Implementations:
    sum(x, option:overflow): -> return_type
    0. sum(DECIMAL<P, S>, option:overflow): -> DECIMAL?<38,S>

    Sum a set of values.

    Options:
  • overflow ['SILENT', 'SATURATE', 'ERROR']
  • avg

    Implementations:
    avg(x, option:overflow): -> return_type
    0. avg(DECIMAL<P,S>, option:overflow): -> DECIMAL<38,S>

    Average a set of values.

    Options:
  • overflow ['SILENT', 'SATURATE', 'ERROR']
  • min

    Implementations:
    min(x): -> return_type
    0. min(DECIMAL<P, S>): -> DECIMAL?<P, S>

    Min a set of values.

    max

    Implementations:
    max(x): -> return_type
    0. max(DECIMAL<P,S>): -> DECIMAL?<P, S>

    Max a set of values.

    sum0

    Implementations:
    sum0(x, option:overflow): -> return_type
    0. sum0(DECIMAL<P, S>, option:overflow): -> DECIMAL<38,S>

    *Sum a set of values. The sum of zero elements yields zero. Null values are ignored. *

    Options:
  • overflow ['SILENT', 'SATURATE', 'ERROR']