Skip to content

functions_arithmetic_decimal.yaml

This document file is generated for functions_arithmetic_decimal.yaml

Scalar Functions

add

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

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(opt_enum:overflow, x, y): -> return_type
    0. subtract(opt_enum:overflow, decimal<P1,S1>, decimal<P2,S2>): ->

    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(opt_enum:overflow, x, y): -> return_type
    0. multiply(opt_enum:overflow, decimal<P1,S1>, decimal<P2,S2>): ->

    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(opt_enum:overflow, x, y): -> return_type
    0. divide(opt_enum:overflow, decimal<P1,S1>, decimal<P2,S2>): ->

    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(opt_enum:overflow, x, y): -> return_type
    0. modulus(opt_enum:overflow, decimal<P1,S1>, decimal<P2,S2>): ->

    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']
  • Aggregate Functions

    sum

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

    Sum a set of values.

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

    Implementations:
    avg(opt_enum:overflow, x): -> return_type
    0. avg(opt_enum:overflow, DECIMAL<P,S>): -> 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.