Please enable JavaScript to view this site.

Program to format a numeric value with a varying number of input decimals and output a value with a specific number of decimals. The result may be rounded and include comma delimiters if required. You may also change the decimal point character to cater for UK and European numbers.

Notes:

If the 'Input value string' contains a minus sign (on the right) then this will be output - see Example 2.

This program only caters for numeric values with a maximum of 10 characters before the decimal point and a maximum of 5 decimal places.

Parameter

In

Len

Out

Len

PARM1

Input value string

132

Output string

132

PARM2

Output decimals (0-5) / Round (R)

2

-

 

PARM3

Thousand delimiter etc.

1

-

 

PARM4

Input Decimal point e.g. “.” or ”,”

1

-

 

PARM5

Output Decimal point e.g. “.” or ”,”

1

-

 

PARM6

Length of output string

2

-

 

Note: It is extremely important that you specify the correct length for your returned value in PARM6 otherwise your output could be truncated.

Example 1

Parameter

Input

Output

PARM1

   1234.679

    1,234.68

PARM2

2R


PARM3

,


PARM4



PARM5



PARM6



Example 2

Parameter

Input

Output

PARM1

   1234.679-

1,234.67-

PARM2



PARM3

,


PARM4



PARM5



PARM6

9


Example 3

Parameter

Input

Output

PARM1

   1234.679

    1.234,68

PARM2

2R


PARM3

.


PARM4

.


PARM5

,


PARM6