"StructuredQuantity" (interpreter type)

Quantity in a standard format.

DetailsDetails

Allowed FormsAllowed Forms

  • The number formats allowed by "Number" are supported for the quantity magnitude.
  • To avoid hitting the Wolfram servers, only units with their canonical forms are supported.

Restriction SpecificationsRestriction Specifications

  • Restricted["Quantity",{{choices1,}}]one among choices
    Restricted["Quantity",unit]convert to unit
    Restricted["Quantity",quantityvariable]restrict to units compatible with the physical quantity of quantityvariable
    Restricted["Quantity",unit,max]a quantity below Quantity[max,unit]
    Restricted["Quantity",unit,{min,max}]a quantity between Quantity[min,unit] and Quantity[max,unit]
    Restricted["Quantity",unit,{min,max,s}]a quantity between Quantity[min,unit] and Quantity[max,unit] with step s
    Restricted["Quantity",quantityvariable,max]a quantity below Quantity[max,unit], with unit the canonical unit of quantityvariable
  • The bounds min and max and step s can also be expressed as quantities.

OptionsOptions

  • The following options can be used for the quantity magnitude:
  • DigitBlockInfinitynumber of digits between breaks
    NumberPoint"."decimal point string
    NumberSeparator{","," "}string to insert at breaks between blocks
    NumberSigns{"-",""}strings to use for signs of negative and positive numbers

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Interpret quantities:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Restrict and convert to a unit:

In[1]:=
Click for copyable input
Out[1]=

Accept unit-less inputs in the presence of an appropriate restriction:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

No connection to the Wolfram Cloud is attempted. Only canonical units (as found in the InputForm) can be used:

In[1]:=
Click for copyable input
Out[1]=

For currency units, the unit conversion is kept symbolical to avoid connecting to the Wolfram Cloud to get the exchange rate:

In[2]:=
Click for copyable input
Out[2]=

Restrict in an interval:

In[1]:=
Click for copyable input
Out[1]=

Change the number separator:

In[1]:=
Click for copyable input
Out[1]=