Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples
Left Hand Pointer


M[UMPS] by Example

Right Hand Pointer

Introduced in the 1990 ANSI M[UMPS] language standard.

This function returns a formatted reproduction of the string passed as a parameter. The actual formatting depends on further parameters.

The first parameter is intended to be a numeric value. The second parameter tells whether or not to include thousands-separators, and what to do with the sign. The third parameter, if any, indicates the number of decimal digits to be included in the result (i.e. where to round the number from the first parameter).

The second parameter is a string value. When this value contains a comma, "thousands" separators will be included in the output value. When this value includes a plus sign, the sign for positive numbers will be included. When this value includes a minus sign, the sign for negative values will be omitted. When this value includes a "p" or a "P", the output value will have parentheses around negative values (no minus-sign, however), and there will be space-characters around positive values. When this value includes a "t" or a "T", the sign will trail the output value, rather than precede it.

Set X=987654123.45

Reference   Value
Set Y=$FNumber(X,",")   "987,654,123.45"
$TRanslate(Y,",.",".,")   "987.654.123,45"

Set X=123.456

Reference   Value
$FNumber(X,"")   "123.456"
$FNumber(X,"P")   "~123.456~"
$FNumber(X,"T")   "123.456~"
$FNumber(X,",")   "123.456"
$FNumber(X,"+")   "+123.456"
$FNumber(X,"-")   "123.456"
$FNumber(-X,"")   "–123.456"
$FNumber(-X,"P")   "(123.456)"
$FNumber(-X,"T")   "123.456-"
$FNumber(-X,",")   "–123.456"
$FNumber(-X,"+")   "–123.456"
$FNumber(-X,"-")   "123.456"
$FNumber(-X,"",2)   "–123.46"
$FNumber(-X,"P",2)   "(123.46)"
$FNumber(-X,"T",2)   "123.46-"
$FNumber(-X,",",2)   "–123.46"
$FNumber(-X,"+",2)   "–123.46"
$FNumber(-X,"-",2)   "123.46"
$FNumber(-X,"",5)   "–123.45600"
$FNumber(-X,"P",5)   "(123.45600)"
$FNumber(-X,"T",5)   "123.45600-"
$FNumber(-X,",",5)   "–123.45600"
$FNumber(-X,"+",5)   "–123.45600"
$FNumber(-X,"-",5)   "123.45600"
$FNumber(-X,"P-")   error (M2)

If the second parameter is an empty string, no editing takes place:

Reference   Value
$FNumber(-X*3,"")   "–370.368"

Note: the three parameter form forces a leading zero on numbers between –1 and +1; the two parameter form does not.

Reference   Value
$FNumber(.123,"+")   "+.123"
$FNumber(.123,"+",3)   "+0.123"
$Justify(.123,7)   "  0.123"
$Justify(.123,7,2)   "   0.12"
$Justify(.123,7,4)   " 0.1230"

0, zero, is neither negative nor positive:

Reference   Value
$FNumber(–1,"+")   "–1"
$FNumber(0,"+")   "0"
$FNumber(1,"+")   "+1"
$FNumber(–1,"-")   "1"
$FNumber(0,"-")   "0"
$FNumber(1,"-")   "1"

Addition in the 1995 ANSI M[UMPS] language standard.

Reference   Value
$FNumber(X,"T",–2)   error (reserved)
Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

Copyright © Standard Documents; 1977-2019 MUMPS Development Committee;
Copyright © Examples: 1995-2019 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2019 Ed de Moel.

The information in this page is NOT authoritative and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an authoritative definition.

Some specifications are "approved for inclusion in a future standard". Note that the MUMPS Development Committee cannot guarantee that such future standards will indeed be published.

This page most recently updated on 13-Sep-2014, 15:50:15 .

For comments, contact Ed de Moel (demoel@jacquardsystems.com)