Difference between revisions of "Math.Number"
m 
m 

Line 145:  Line 145:  
}  }  
+  [[Category:Dictionary of expressions]]  
[[Category:Expressions with internal state]]  [[Category:Expressions with internal state]]  
[[Category:Expressions in the Standard arithmetic package]]  [[Category:Expressions in the Standard arithmetic package]]  
[[Category:Irreducible expressions]]  [[Category:Irreducible expressions]]  
[[Category:Expressions with localized implementations]]  [[Category:Expressions with localized implementations]] 
Revision as of 12:00, 4 September 2018
It is the tag for the expression representing an integer or decimal real number.
Definition
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.
Visualization
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.
Edition
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.
Reduction
Since this expression is not expected to be reduced to a different one, no reducers are currently known.
Known implementations
The Standard Arithmetic Package
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.
Visualization
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 HinduArabic 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 righttoleft written languages, such as Arabic or Hebrew, when using HinduArabic numerals to represent numbers.
 Numbers are shown with no leading zeroes before the integer part, unless its integer part is zero.
 Numbers are shown with no trailing zeroes after the fractional part (if any).
 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.
 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.  1 234,  1.234, 
Decimal number with no integer part  0.567  0,567  0,567 
Integer zero  0  0  0 
Decimal zero  0.  0,  0, 
Edition
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.
Examples
Example  Edition/Action performed  Result 

Edition "Creates a number" 

Action "Edition of a number" 
Programming
Internal state
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.
Access
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 
Serialization
Attribute name  Serialized form 

"Value"  The string containing a representation of the number, with the following considerations:

Examples:
There is no predefined format for expression serialization. The following are examples of Math.Number expression in XML format:
Number  XML format 

123,456,789  <expression Tag="Math.Number" Value="123456789" />

3.14  <expression Tag="Math.Number" Value="3.14" />

Integer 38  <expression Tag="Math.Number" Value="38" />

Decimal 38  <expression Tag="Math.Number" Value="38." />
