Help:Datatype "Number"

Jump to: navigation, search
Holds integer and decimal numbers, with an optional exponent
Further Information
Provided by: Semantic MediaWiki
Added in version: 1.0
Removed in version: still in use
Datatype ID:
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.

It is possible to use units of measurement with number values. They can be specified as arbitrary non-numerical strings after the number. Though Type: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 for custom units for further information on this.

Numbers 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.

Plain printout format for queries

The results for queries on properties of datatye Number can be displayed without a ',' or '.' as separators for thousands. This is needed in case you, e.g. want to use the results as input values for the construction of items like URLs. You can achieve this by using the symbol '#' with or without a following hyphen '-'. See also the help page on creating plain printouts.

Plain result {{#show: Berlin | ?population# }} instead of formatted result {{#show: Berlin | ?population }}. → Plain result 3520061 instead of formatted result 3,520,061.

Types Float and Integer

Type: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 Type:Number since SMW 1.0.

Related query syntax elements


Help pageSyntax elementDescription
#ask: annotation query marker
Marks an inline query as part of an annotation1
#ask: control query marker
Allows to dynamically alter a result display without the need to reload a page2
#ask: deferred query marker
Marks an inline query as deferred from regular parsing2
#ask: hierarchy depth restriction
Restricts the hierarchy depth of a query3
#ask: printout column width
Defines a width for a printout column4
#ask: printout column width
Defines an alignment for the content of a printout column

This documentation page applies to all SMW versions from 1.6.0 to the most current version.
Other versions: 1.0 – 1.5.6       Other languages: dezh-hans

Help:Type Number en 1.6.0


  1. ^  Semantic MediaWiki: GitHub pull request gh:smw:2572
  2. a b  Semantic MediaWiki: GitHub pull request gh:smw:2398 (Add support for @deferred mode)
  3. ^  Semantic MediaWiki: GitHub issue gh:smw:2662
  4. ^  Semantic MediaWiki: GitHub pull request gh:smw:2677