@@ -356,5 +356,54 @@ scalar_functions:
356356 AWAY_FROM_ZERO, TIE_DOWN, TIE_UP, TIE_TOWARDS_ZERO, TIE_TO_ODD ]
357357 nullability : DECLARED_OUTPUT
358358 return : |-
359- S2 = iff(s > 0, s, 0)
360- decimal?<P1,S2>
359+ decimal?<38,S1>
360+ -
361+ name : " fixed_round"
362+ description : >
363+ Rounding the value `x` to `s` decimal places.
364+ impls :
365+ - args :
366+ - value : decimal<P1,S1>
367+ name : " x"
368+ description : >
369+ Numerical expression to be rounded.
370+ - value : decimal<38,0>
371+ constant : true
372+ name : " s"
373+ description : >
374+ Number of decimal places to be rounded to.
375+
376+ When `s` is a positive number, the rounding
377+ is performed to a `s` number of decimal places.
378+
379+ When `s` is a negative number, the rounding is
380+ performed to the left side of the decimal point
381+ as specified by `s`.
382+ options :
383+ rounding :
384+ description : >
385+ When a boundary is computed to lie somewhere between two values,
386+ and this value cannot be exactly represented, this specifies how
387+ to round it.
388+
389+ - TIE_TO_EVEN: round to nearest value; if exactly halfway, tie
390+ to the even option.
391+ - TIE_AWAY_FROM_ZERO: round to nearest value; if exactly
392+ halfway, tie away from zero.
393+ - TRUNCATE: always round toward zero.
394+ - CEILING: always round toward positive infinity.
395+ - FLOOR: always round toward negative infinity.
396+ - AWAY_FROM_ZERO: round negative values with FLOOR rule, round positive values with CEILING rule
397+ - TIE_DOWN: round ties with FLOOR rule
398+ - TIE_UP: round ties with CEILING rule
399+ - TIE_TOWARDS_ZERO: round ties with TRUNCATE rule
400+ - TIE_TO_ODD: round to nearest value; if exactly halfway, tie
401+ to the odd option.
402+ values : [ TIE_TO_EVEN, TIE_AWAY_FROM_ZERO, TRUNCATE, CEILING, FLOOR,
403+ AWAY_FROM_ZERO, TIE_DOWN, TIE_UP, TIE_TOWARDS_ZERO, TIE_TO_ODD ]
404+ nullability : DECLARED_OUTPUT
405+ return : |-
406+ S2 = (s > 0) ? min(s, S1) : 0
407+ P2 = (s > 0) ? ((S1 >= s) ? P1 : (P1 + 1)) : ((P1 + s >= S1) ? P1 + 1 : (S1 - s + 1))
408+ P2 = min(38, P2);
409+ decimal?<P2,S2>
0 commit comments