Difference between revisions of "NumberFormat"

m (fixed closing tag)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Attributes]]
+
[[Category: Number formats]]
 +
[[Category: Attributes]]
 +
{{ReleaseBar}}
  
= NumberFormat Attribute =
+
== NumberFormat attribute ==
  
This attribute records the Number Format settings for a variable.
+
This attribute records the Number Format settings for a variable.  Each variable has a single number format. It uses the default format set for the model unless you have set a specific format for the variable.  If the value is an array -- a table of values -- you can use [[Cell format dialog]] to set different formats for each cell, row, column, or slice. This information is stored in the [[Att_CellFormat]] Attribute.  If the definition is a Table (or Multitable) that contains other variables or indexes as elements, the resulting table (Array) uses the Number format set for those variables or indexes, unless you override them with Cell formats for this table.
  
In Analytica, only one number format is associated with any one objectTo use multiple different number formats in a single table, you must have multiple objects (variables) storing each of the number formats.  If you have a self-index consisting of identifiers (or define your result as a list of identifiers), the number format for each column will be taken from the variable who identifier heads that self-index column.
+
== Format ==
 +
The [[NumberFormat]] attribute has the following format:
 +
: 2, formatcode, proxy, zeroes, separators, currency, digits, trailingZeros, currencysymbol,  currencyPlacement, datetemplate, ''fullPrecision'', fullDateTemplate, relReqForFullDateTemplate, datesAsNumbers, numbersAsDates, digitsForGeneralFmt{{Release|6.0||,GigaOrMuSuffixChars}}{{Release|6.3||,showZeroImPart}}
 +
 
 +
where:
 +
 
 +
First field is the version number of the number format
 +
;<code>«formatcode»</code> (item 2): is one of:
 +
::<code>D</code>: Suffix
 +
::<code>E</code>: Exponential
 +
::<code>F</code>: Fixed point
 +
::<code>I</code>: Integer
 +
::<code>%</code>: Percent
 +
::<code>DD</code>: Date
 +
::<code>DB</code>: Boolean
 +
;<code>«'''proxy'''» (item 3)</code> : When format code is a date, this is set to <code>0</code>, <code>1</code>, or <code>2</code> based on datetypeFor a non-date, same as digits.  This is not used  directly, but is set like this to be upward compatible with Analytica 3.1 and before.
 +
;<code>«zeroes»</code> (item 4):  Number of digits after the decimal in fixed point and percent formats.
 +
;<code>«separators»</code> (item 5): <code>0</code> or <code>1</code>, whether commas are used
 +
;<code>«currency»</code> (item 6): <code>0</code> or <code>1</code>, whether currency symbol is shown
 +
;<code>«digits»</code> (item 7): Number of digits for exponent and suffix types.
 +
;<code>«trailingZeros»</code> (item 8): boolean<code>True</code> = add trailing zeros to fill out precision
 +
;<code>«currencySymbol»</code> (item 9): Multi-character symbol used for currency. Blank will use regional currency symbol.
 +
;<code>«currencyPlacement»</code> (item 10): One of these values:
 +
::<code>0</code> = $-x
 +
::<code>1</code> = -$x
 +
::<code>2</code> = -x$
 +
::<code>3</code> = $x-
 +
::<code>4</code> = x$-
 +
::<code>5</code> = x-$
 +
::<code>6</code> = ($x)
 +
::<code>7</code> = (x$)
 +
::<code>8</code> = use regional setting
 +
;<code>«datetemplate»</code> (item 11):  A string composed of these fields
 +
::<code>y</code> = Two digit year with no leading zero, e.g., 5
 +
::<code>yy</code> = Two digit year, e.g., 05
 +
::<code>yyyy</code> = Four digit year, e.g., 2005
 +
::<code>M</code> = Numeric month (no leading zero), e.g., 4
 +
::<code>MM</code> = Numeric month w/leading zero, e.g., 04
 +
::<code>MMM</code> = Abbreviated month, e.g., Apr
 +
::<code>MMMM</code> = Full month name, e.g., April
 +
::<code>d</code> = day of month, e.g., 9
 +
::<code>dd</code> = day of month w/leading zero, e.g., 09
 +
::<code>ddd</code> = abbreviated ordinal day of month, English only, e.g., 9th
 +
::<code>dddd</code> = Ordinal day of month, English only, e.g., ninth
 +
::<code>Dddd</code> = Ordinal day of month, capitalized, e.g., Ninth
 +
::<code>www</code> = Abbreviated weekday name
 +
::<code>wwww</code> = Weekday name, e.g., Saturday
 +
::<code>q</code> = quarter, 1 through 4, e.g., 2
 +
::<code>LONG</code> : regional long date format, e.g., Saturday, April 9, 2005
 +
::<code>SHORT</code>: regional short date format, e.g., 4/09/05
 +
::<code>ABBREV</code> : abbreviated version of long date format, e.g., Tue, Apr 9, 2005
 +
::<code>SABBREV</code> : abbreviated version of long date format w/o weekday, e.g., Apr 9, 2005
 +
::<code>SLONG</code> : regional long date with weekday stripped, e.g., April 9, 2005
 +
:::&rsquo;&rsquo;&rsquo;&rsquo; : A single quote, e.g., "MMM &rsquo;&rsquo;&rsquo;&rsquo;yy" would be to produce "Apr '05"
 +
:::The doubled ' inside escapes the '.
 +
:: Literal characters: /, -, [dot], [space], [comma]
 +
::: 'text' : literal text, e.g., 'Q'q could produce Q2
 +
;<code>«fullPrecision»</code> (item 12): (optional), <code>0</code> or <code>1</code> (default <code>0</code>) : whether full precision is required always
 +
;<code>«fullDateTemplate»</code> (item 13): (optional) The date template used instead of «dateTemplate» when running in a release «relReqForFullDateTemplate» or later. This is used for backward compatibility legacy support.
 +
;<code>«relReqForFullDateTemplate»</code> (item 14): (optional) A release number as a number major*10K+minor*100+patch, e.g., 50104 for release 5.1.4. The minimum release at which «fullDateTemplate» is preferred to «dateTemplate».
 +
;<code>«datesAsNumbers»</code> (item 15): (optional) 0 or 1. When 1, date and date-time numbers are displayed as numbers -- as the number of days past the date origin.
 +
;<code>«numbersAsDates»</code> (item 16): (optional) 0 or 1. When 1, numbers are displayed as dates, and are interpreted as the number of days after the date origin.
 +
;<code>«digitsForGeneralFmt»</code> (item 17): (optional) This is the number of digits used when the General format is selected (in [[Analytica 5.0]]).{{Release|6.0||
 +
;<code>«GigaOrMuSuffixChars»</code> (item 18): (optional) Customizes the characters used to display <math>10^{12}</math> or <math>10^{-6}</math> suffix characters. Can contain B, G, u or µ, or two of these, e.g., Bµ.  See also [https://lumina.com/community/models-and-application-examples/displaying-b-for-billion-%c2%b5-for-micro/ Displaying B for billion, µ for micro]] ([https://lumina.com/community a Forum posting]).}}{{Release|6.3||
 +
;<code>«showZeroImPart»</code>(item 19): (optional) Controls whether a complex number with a zero imaginary part displays <code>+0j</code>. }}
  
== Format ==
+
== History ==
 +
In Analytica 1.0 through 3.1, the [[NumberFormat]] was:
  
The number format has the following format:
+
: 1, formatcode, digits, zeroes, separators, currency
 +
where:
  
    2, formatcode, proxy, zeroes, separators, currency,
+
First field is version number
      digits, trailingZeros, currencysymbol, currencyPlacement,
+
;<code>«formatcode»</code> :is one of:
      datetemplate, fullPrecision
+
::<code>D</code>: Suffix
&nbsp;
+
::<code>E</code>: Exponential
where:
+
::<code>F</code>: Fixed point
    - First field is version #
+
::<code>I</code>: Integer
    - Format code: is same as in version 1.
+
::<code>%</code>: Percent
    - Proxy : When format code is a date, this is
+
::<code>DD</code>: Date
        set to 0, 1, or 2 based on datetype.  For a
+
::<code>DB</code>: Boolean
        non-date, same as digits.  This is not used
+
;<code>«digits»</code>: Specified number of digits for exponent and suffix types, or the date type as follows:
        directly, but is set like this to be upward
+
::<code>0</code> = Short
        compatible with version 3.1 and before.
+
::<code>1</code> = Long
    - zeroes: same as in version 1
+
::<code>2</code> = Abbrev
    - separators: 0 or 1, same as in version 1
+
;<code>«zeroes»</code>: Number of digits after the decimal in fixed point and percent formats.
    - currency: 0 or 1, same as in version 1
+
;<code>«separators»</code>: <code>0</code> or <code>1</code>, whether commas are used
    - trailingZeros: boolean.  True=add trailing zeros to fill out precision
+
;<code>«currency»</code>: <code>0</code> or <code>1</code>, whether currency symbol is shown
    - digits: # digits for exponent and suffix types.
 
    - currencySymbol: Multi-character symbol used for
 
          currency. Blank will use regional currency
 
          symbol.
 
    - currencyPlacement: One of these values:
 
          0 = $-x
 
          1 = -$x
 
          2 = -x$
 
          3 = $x-
 
          4 = x$-
 
          5 = x-$
 
          6 = ($x)
 
          7 = (x$)
 
          8 = use regional setting
 
    - date template: A string composed of these fields:
 
        Using
 
        y = Two digit year with no leading zero, e.g., 5
 
        yy = Two digit year, e.g., 05
 
        yyyy = Four digit year, e.g., 2005
 
        M = Numeric month (no leading zero), e.g., 4
 
        MM = Numeric month w/leading zero, e.g., 04
 
        MMM = Abbreviated month, e.g., Apr
 
        MMMM = Full month name, e.g., April
 
        d = day of month, e.g., 9
 
        dd = day of month w/leading zero, e.g., 09
 
        ddd = abbreviated ordinal day of month, English only, e.g., 9th
 
        dddd= Ordinal day of month, English only, e.g., ninth
 
        Dddd= Ordinal day of month, capitalized, e.g., Ninth
 
        www = Abbreviated weekday name
 
        wwww = Weekday name, e.g., Saturday
 
        q = quarter, 1 through 4, e.g., 2
 
        LONG : regional long date format, e.g., Saturday, April 9, 2005
 
        SHORT: regional short date format, e.g., 4/09/05
 
        ABBREV : abbreviated version of long date format, e.g., Tue, Apr 9, 2005
 
        SABBREV : abbreviated version of long date format w/o weekday, e.g., Apr 9, 2005
 
        SLONG : regional long date with weekday stripped, e.g., April 9, 2005
 
                  &rsquo;&rsquo;&rsquo;&rsquo; : A single quote, e.g., "MMM &rsquo;&rsquo;&rsquo;&rsquo;yy" would be to produce "Apr \'05"
 
                  The doubled ' inside escapes the '.
 
        Literal characters: /, -, [dot], [space], [comma]
 
                  'text' : literal text, e.g., 'Q'q could produce Q2
 
    - fullPrecision (opt): 0 or 1 (default 0) : whether full precision is req always
 
  
= Analytica 3.1 =
+
The «GigaOrMuSuffixChars» field (item 18) is new in [[Analytica 6.0]].
  
In Analytica 1.0 through 3.1, the format was:
+
The «showZeroImPart» field (item 19) is new in [[Analytica 6.3]].
  
    1, formatcode, digits, zeroes, separators, currency
+
==See Also==
&nbsp;
+
* [[Cell format dialog]] to set formats for each cell, row, column or slice of an array.
Where:
+
* [[Computed cell formats]] to compute the color, font style, or other format of a cell based on its value.
    - First field is version #
+
* [[NumberToText]] to convert numbers to text with specified format.
    - format code is one of:
+
* [[ParseNumber]] to parse text into a number.
        D : Suffix
+
* [[Numbers]] syntax and forms of numbers
        E : Exponential
 
        F : Fixed point
 
        I : Integer
 
        % : Percent
 
        DD: Date
 
        DB: Boolean
 
    - digits: Specifies # of digits for exponent and suffix
 
              types, or the date type as follows:
 
          0 = Short
 
          1 = Long
 
          2 = Abbrev
 
    - zeroes: # of digits after the decimal in fixed point
 
        and percent formats.
 
    - separators: 0 or 1, whether commas are used
 
    - currency: 0 or 1, whether currency symbol is shown
 

Latest revision as of 20:29, 27 December 2022



Release:

4.6  •  5.0  •  5.1  •  5.2  •  5.3  •  5.4  •  6.0  •  6.1  •  6.2  •  6.3  •  6.4  •  6.5


NumberFormat attribute

This attribute records the Number Format settings for a variable. Each variable has a single number format. It uses the default format set for the model unless you have set a specific format for the variable. If the value is an array -- a table of values -- you can use Cell format dialog to set different formats for each cell, row, column, or slice. This information is stored in the Att_CellFormat Attribute. If the definition is a Table (or Multitable) that contains other variables or indexes as elements, the resulting table (Array) uses the Number format set for those variables or indexes, unless you override them with Cell formats for this table.

Format

The NumberFormat attribute has the following format:

2, formatcode, proxy, zeroes, separators, currency, digits, trailingZeros, currencysymbol, currencyPlacement, datetemplate, fullPrecision, fullDateTemplate, relReqForFullDateTemplate, datesAsNumbers, numbersAsDates, digitsForGeneralFmt,GigaOrMuSuffixChars,showZeroImPart

where:

First field is the version number of the number format

«formatcode» (item 2)
is one of:
D: Suffix
E: Exponential
F: Fixed point
I: Integer
%: Percent
DD: Date
DB: Boolean
«proxy» (item 3)
When format code is a date, this is set to 0, 1, or 2 based on datetype. For a non-date, same as digits. This is not used directly, but is set like this to be upward compatible with Analytica 3.1 and before.
«zeroes» (item 4)
Number of digits after the decimal in fixed point and percent formats.
«separators» (item 5)
0 or 1, whether commas are used
«currency» (item 6)
0 or 1, whether currency symbol is shown
«digits» (item 7)
Number of digits for exponent and suffix types.
«trailingZeros» (item 8)
boolean. True = add trailing zeros to fill out precision
«currencySymbol» (item 9)
Multi-character symbol used for currency. Blank will use regional currency symbol.
«currencyPlacement» (item 10)
One of these values:
0 = $-x
1 = -$x
2 = -x$
3 = $x-
4 = x$-
5 = x-$
6 = ($x)
7 = (x$)
8 = use regional setting
«datetemplate» (item 11)
A string composed of these fields
y = Two digit year with no leading zero, e.g., 5
yy = Two digit year, e.g., 05
yyyy = Four digit year, e.g., 2005
M = Numeric month (no leading zero), e.g., 4
MM = Numeric month w/leading zero, e.g., 04
MMM = Abbreviated month, e.g., Apr
MMMM = Full month name, e.g., April
d = day of month, e.g., 9
dd = day of month w/leading zero, e.g., 09
ddd = abbreviated ordinal day of month, English only, e.g., 9th
dddd = Ordinal day of month, English only, e.g., ninth
Dddd = Ordinal day of month, capitalized, e.g., Ninth
www = Abbreviated weekday name
wwww = Weekday name, e.g., Saturday
q = quarter, 1 through 4, e.g., 2
LONG : regional long date format, e.g., Saturday, April 9, 2005
SHORT: regional short date format, e.g., 4/09/05
ABBREV : abbreviated version of long date format, e.g., Tue, Apr 9, 2005
SABBREV : abbreviated version of long date format w/o weekday, e.g., Apr 9, 2005
SLONG : regional long date with weekday stripped, e.g., April 9, 2005
’’’’ : A single quote, e.g., "MMM ’’’’yy" would be to produce "Apr '05"
The doubled ' inside escapes the '.
Literal characters: /, -, [dot], [space], [comma]
'text' : literal text, e.g., 'Q'q could produce Q2
«fullPrecision» (item 12)
(optional), 0 or 1 (default 0) : whether full precision is required always
«fullDateTemplate» (item 13)
(optional) The date template used instead of «dateTemplate» when running in a release «relReqForFullDateTemplate» or later. This is used for backward compatibility legacy support.
«relReqForFullDateTemplate» (item 14)
(optional) A release number as a number major*10K+minor*100+patch, e.g., 50104 for release 5.1.4. The minimum release at which «fullDateTemplate» is preferred to «dateTemplate».
«datesAsNumbers» (item 15)
(optional) 0 or 1. When 1, date and date-time numbers are displayed as numbers -- as the number of days past the date origin.
«numbersAsDates» (item 16)
(optional) 0 or 1. When 1, numbers are displayed as dates, and are interpreted as the number of days after the date origin.
«digitsForGeneralFmt» (item 17)
(optional) This is the number of digits used when the General format is selected (in Analytica 5.0).
«GigaOrMuSuffixChars» (item 18)
(optional) Customizes the characters used to display [math]\displaystyle{ 10^{12} }[/math] or [math]\displaystyle{ 10^{-6} }[/math] suffix characters. Can contain B, G, u or µ, or two of these, e.g., Bµ. See also Displaying B for billion, µ for micro] (a Forum posting).
«showZeroImPart»(item 19)
(optional) Controls whether a complex number with a zero imaginary part displays +0j.

History

In Analytica 1.0 through 3.1, the NumberFormat was:

1, formatcode, digits, zeroes, separators, currency

where:

First field is version number

«formatcode»
is one of:
D: Suffix
E: Exponential
F: Fixed point
I: Integer
%: Percent
DD: Date
DB: Boolean
«digits»
Specified number of digits for exponent and suffix types, or the date type as follows:
0 = Short
1 = Long
2 = Abbrev
«zeroes»
Number of digits after the decimal in fixed point and percent formats.
«separators»
0 or 1, whether commas are used
«currency»
0 or 1, whether currency symbol is shown

The «GigaOrMuSuffixChars» field (item 18) is new in Analytica 6.0.

The «showZeroImPart» field (item 19) is new in Analytica 6.3.

See Also

Comments


You are not allowed to post comments.