|Holds integer and decimal numbers, with an optional exponent|
|Provided by:||Semantic MediaWiki|
|Until version:||still in use|
|In this wiki:||Number|
|Table of Contents|
The datatype number is used for properties that contain any kind of number, integer, decimal, and floating point numbers. It can be positive or negative, with thousand separators, and it can have an optional exponent. For example, "42", "-273.15" and "4,297.31 e7" are valid numbers. The permitted range of numbers can be restricted using special property "Allows value"Lists one permissible value for a property.
Datatype Number is a universal replacement for the separate datatypes Float and Integer used in early versions of Semantic MediaWiki. Integer and Float are aliases for datatype Number since Semantic MediaWiki 1.0Released on 31 December 2007 and compatible with MW 1.9.x - 1.12.x..
Units of measurements
It is possible to use units of measurement with number values. They can be specified as arbitrary non-numerical strings after the number. Though datatype Number does not understand units (i.e. it performs no automatic conversion), a unit can be used to distinguish property values with different units to avoid accidental comparison of quantities that have been given in different units. It is also possible to define a property that is aware of units. See the help page on custom units for further information on this.
Since Semantic MediaWiki 2.4.0Released on 9 July 2016 and compatible with MW 1.19.0 - 1.27.x. it is also possible to define the display precision for a property of datatype "Number". See the help page on display precision for further information on this.
In other languages
Numbers are written differently in different languages, and some of these differences are taken into account by Semantic MediaWiki. In particular, there is no global consensus on how to write the decimal separator ("." in English) and the thousands separators ("," in English). When using Semantic MediaWiki in a wiki that does not use English as a content language, the format for numbers might change according to the local customs. For example, German numbers use "," as a decimal separator and "." as a thousands separator, so German "1,234" is the same as English "1.234" not "1234".
Note that the thousands (kilo) separator is optional, and is used only for formatting in some languages where it is not needed for the input. For example, French numbers group thousands with spaces, which is allowed anyway, and thus their thousands separator is a non-breakable space even though this will rarely be typed by users when writing numbers.
In recent versions of SMW, both the decimal separator and the thousands separators are determined by the wiki language using MediaWikis i18n system. So you cannot change the symbols used yourself.
Displaying information in queries
- API example
- Help page on custom units
- Help page on special property "Corresponds to"Gives the conversion factor for some unit of a physical quantity and the possible names for that unit
- Help page on display precision
- Help page on special property "Display precision of"Allows to define the display precision in digits
- Help page on displaying information in inline queries
- Help page on special property "Allows value"Lists one permissible value for a property