Caché ObjectScript Reference
$FNUMBER


Search: 
$FNUMBER(inumber,format,decimal) $FN(inumber,format,decimal)
The number to be formatted. It can be a numeric literal, a variable, or any valid ObjectScript expression that evaluates to a numeric value.  
Code  Description 

""  Empty string. Returns 
+  Returns a nonnegative number prefixed by the PlusSign property of the current locale (“+” by default). If the number is negative, it returns the number prefixed by the MinusSign property of the current locale (“” by default). 
  Returns the absolute value of a number. Always returns a negative number without the MinusSign character. Returns a positive number without the PlusSign character. When combined with the “+” format code ( 
,  Returns the number with the value of the NumericGroupSeparator property of the current locale inserted every NumericGroupSize numerals to the left of the decimal point. Combining “,” with either “.” or “N” formats results in a <FUNCTION> error. 
.  Returns the number using standard European formatting, regardless of the current locale settings. Sets DecimalSeparator to comma (,), NumericGroupSeparator to period (.), NumericGroupSize to 3, PlusSign to plus (+), MinusSign to minus (). Combining “.” with either “,” or “O” formats results in a <FUNCTION> error. 
D  $DOUBLE special formatting. This code has two effects: “D” specifies that $DOUBLE(0) should return 0; otherwise, $DOUBLE(0) returns 0. However, “D” overrides the negative sign and returns 0. You can specify “D” or “d” for this code; a returned INF or NAN will be expressed in the corresponding uppercase or lowercase letters. The default is upper case. 
E  Enotation (scientific notation). Returns the number in scientific notation. If you omit the 
G  Enotation or fixed decimal notation. If the number of fractional digits that would result from conversion to scientific notation is larger than the 
L  Leading sign. Sign, if present, must precede the numerical portion of 
N  No NumericGroupSeparator. Does not allow the use of a numeric group separator. This format code is incompatible with the comma (,) format code. When used with the dot format code ( 
O  ODBC locale. Overrides the current locale, and instead uses the standard ODBC locale with the following values: PlusSign=+; MinusSign=; DecimalSeparator=.; NumericGroupSeparator=,; NumericGroupSize=3. By itself, the “O” format code uses only the ODBC MinusSign and DecimalSeparator. This format code is incompatible with the dot (.) format code. When used with the comma format code ( 
P  Parentheses sign. Returns a negative number in parentheses and without a leading MinusSign locale property value. Otherwise, it returns the number without parentheses, but with a leading and trailing space character. This code cannot be used with the “+”, “”, “L”, or “T” format codes; attempting to do so results in a <SYNTAX> error. 
T  Trailing sign. Returns the number with a trailing sign if a prefix sign would otherwise have been generated. However, it does not force a trailing sign. To produce a trailing sign for a nonnegative number (positive or zero), you must also specify the “+” format code. To produce a trailing sign for a negative number, you must 
SET a=1234 WRITE $FNUMBER(a),! ; returns 1234 WRITE $FNUMBER(a,""),! ; returns 1234 WRITE $FNUMBER(a,"+"),! ; returns +1234 WRITE $FNUMBER(a,""),! ; returns 1234 WRITE $FNUMBER(a,"L"),! ; returns 1234 WRITE $FNUMBER(a,"T"),! ; returns 1234 (with a trailing space) WRITE $FNUMBER(a,"T+"),! ; returns 1234+
SET b=1234 WRITE $FNUMBER(b,""),! ; returns 1234 WRITE $FNUMBER(b,"+"),! ; returns 1234 WRITE $FNUMBER(b,""),! ; returns 1234 WRITE $FNUMBER(b,"L"),! ; returns 1234 WRITE $FNUMBER(b,"T"),! ; returns 1234
WRITE "*",$FNUMBER(123,"P"),"*",! ; returns *(123)* WRITE "*",$FNUMBER(123,"P"),"*",! ; returns * 123 *
WRITE ##class(%SYS.NLS.Format).GetFormatItem("NumericGroupSeparator"),! WRITE ##class(%SYS.NLS.Format).GetFormatItem("NumericGroupSize")
WRITE ##class(%SYS.NLS.Format).GetFormatItem("PlusSign"),! WRITE ##class(%SYS.NLS.Format).GetFormatItem("MinusSign")
Copyright © 19972019, InterSystems Corporation

Content for this page loaded from RCOS_ffnumber.xml on 20190612 19:53:49
