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" | |
$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.