M[UMPS] Functions - $FN[UMBER]
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
SET X=123.456
If the second parameter is an empty string, no editing takes place:
Note: the three parameter form forces a leading zero on numbers between -1 and +1; the two parameter form does not.
0, zero, is neither negative nor positive:
Addition in the 1995 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 ( |
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" | |
| $JUSTFY(.123,7) | " 0.123" | |
| $JUSTFY(.123,7,2) | " 0.12" | |
| $JUSTFY(.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) |
This document is © Ed de Moel, 1995-2005.
It is part of a book by Ed de Moel that is published under the title "M[UMPS] by Example" (ISBN 0-918118-42-5).
Printed copies of the book are no longer available.
This document describes the various operators that are defined in the M[UMPS] language standard (ANSI X11.1, ISO 11756).
The information in this document is NOT authoritative and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an authoritative definition.
In this document, information is included that will appear in future standards.
The MDC cannot guarantee that these 'next' standards will indeed appear.
It is part of a book by Ed de Moel that is published under the title "M[UMPS] by Example" (ISBN 0-918118-42-5).
Printed copies of the book are no longer available.
This document describes the various operators that are defined in the M[UMPS] language standard (ANSI X11.1, ISO 11756).
The information in this document is NOT authoritative and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an authoritative definition.
In this document, information is included that will appear in future standards.
The MDC cannot guarantee that these 'next' standards will indeed appear.