It is the tag for the expression representing an integer or decimal real number.
- 1 Definition
- 2 Known implementations
- 3 Programming
According with the Fōrmulæ Arithmetic canon, number expressions must have the following properties:
- They represent only either positive real numbers or zero. A negative number should be represented by a Math.Arithmetic.Negative expression containing a Math.Number expression as its only child.
- There are two types: Integer and decimal numbers. Integer numbers can represent only integer values, while decimal numbers can represent both integer and fractional values.
This expression must have no children.
This expression has internal state, which is an internal value of the number it contains. The format of this number —floating point, arbitrary precision, etc.— depends of the particular implementation.
There could be different visualizations, according with specific features, such like showing big numbers in scientific notation, showing numbers in different numeral systems, or for localization purposes.
Independently of the visualization method, there should be a way to differentiate the visualization of an integer number from a decimal number with no fractional part.
When editing the number to be created or modified, there should be a way to differentiate when introducing an integer number from a decimal number with no fractional part.
Since this expression is not expected to be reduced to a different one, no reducers are currently known.
This package provides an implementation of the Math.Number expression, which supports the following features:
- Arbitrary precision, this is, it can hold integer numbers with any number of digits, and decimal numbers with any number of digits on its integer and decimal part. There is a limit, but it is imposed by memory availability, not by design.
- Localization. Numbers are introduced and shown accordingly to the user locale.
There is one visualization on this package, which shows numbers accordingly to the following:
- Numbers are always shown in base 10.
- Numbers are always shown using Hindu-Arabic numerals, This is, the symbols 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 from the Latin alphabet. The symbol used as a decimal separator is locale dependent. This usage is increasing —to represent numbers— even in languages that traditionally use other alphabets, such as Kanji, Greek, Hebrew or Cyrillic.
- Numbers are always shown left to right. It is a common practice even in right-to-left written languages, such as Arabic or Hebrew, when using Hindu-Arabic numerals to represent numbers.
- Numbers are shown with no leading zeroes before the integer part, unless its integer part is zero.
- Decimal numbers are shown with no trailing zeroes after the fractional part, unless they hold integer values, in such a case there is only one trailing zero, for example in 5.0
- Number are not shorten in any way —i.e. scientific notation—, so be careful because either big numbers or numbers with many decimal places will could produce visually very wide results.
- In order to differentiate integer numbers from decimal numbers with no fractional part, the latter is always shown with a trailing decimal separator and a zero.
- The integer part of the number (if any) is shown separated by a group separator, usually every three places. This symbol is locale dependent.
The following shows examples of this visualization on different numbers, in several locales:
|Number type||Example in United States||Example in France||Example in Italy|
|Integer number||1,234||1 234||1.234|
|Decimal number with fractional part||1,234.567||1 234,567||1.234,567|
|Decimal number with no fractional part||1,234.0||1 234,0||1.234,0|
|Decimal number with no integer part||0.567||0,567||0,567|
When a number is created or modified the user should write the number with a trailing decimal point when introducing a decimal number with no fractional part, in order to differentiate it from an integer.
When a number expression is created, it substitutes the previous selected expression. After the creation, the number expression becames the selected expression.
Edition "Creation of a number"
Since this expression has internal state, it opens a dialog box in order that the user can write the number. The new Math.Number expression substitutes the current selected expression and becames the new selected expression.
Action "Edition of a number"
Since this expression has internal state, it opens a dialog box in order that the user can write the new number. The internal number of the Math.Number currently selected is changed to the new value.
| Edition "Creates a number"
| Action "Edition of a number"
Being an expression with internal state, implementations of this expression must provide the necessary to access this state, and to provide a string representation of this state to be serialized.
|Programming language||Attribute name||Object retrieved||Notes|
|Java||"Value"|| A BigInteger object reference containing the number, if it is integer
A BigDecimal object reference containing the number, if it is decimal
|BigInteger or BigDecimal object must be retrieved even if a particular implementation does not support arbitrary precision|
|Attribute name||Serialized form|
|"Value"|| The string containing a representation of the number, with the following considerations:
There is no predefined format for expression serialization. The following are examples of Math.Number expression in XML format:
|Integer 38|| |
|Decimal 38|| |