Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { round } from 'lodash-es';
import { AmaliaFunctionCategory, AmaliaFunctionKeys, type AmaliaFormula } from '@amalia/amalia-lang/formula/types';
import { AmaliaFunctionDefault } from '../../AmaliaFunction';
export const numbersRound = new AmaliaFunctionDefault<[number, number], number>({
name: AmaliaFunctionKeys.ROUND,
category: AmaliaFunctionCategory.NUMBERS,
nbParamsRequired: 1,
description: 'Return a rounded number',
exec: (numberInput, nbDecimals) => round(numberInput, nbDecimals),
hiddenFromLibrary: true,
params: [
{ name: 'input', description: 'Input number to round: numbers, fields, properties, variables' },
{
name: 'nbDecimals',
description: 'The number of decimal places of the rounded output. By default it is 0.',
defaultValue: '0',
},
],
examples: [
{
desc: 'Returns 5',
formula: 'ROUND(5.3)' as AmaliaFormula,
result: 5,
},
{
desc: 'Returns 1.7',
formula: 'ROUND(1.68, 1)' as AmaliaFormula,
result: 1.7,
},
{
desc: 'Returns 1.57',
formula: 'ROUND(1.573, 2)' as AmaliaFormula,
result: 1.57,
},
{
desc: 'Returns the rounded Commission with 2 decimal places.',
formula: 'ROUND(statement.commission, 2)',
},
{
desc: 'Returns 150',
formula: 'ROUND(154, -1)' as AmaliaFormula,
result: 150,
},
],
});
|