"StructuredQuantity" (Interpreter Type)
Quantity in a standard format.
Details
- "StructuredQuantity" can be used in Interpreter and related constructs, including deployed smart form fields.
- Use of "StructuredQuantity" does not require connectivity to the Wolfram Cloud.
Allowed 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 Specifications
-
Restricted["StructuredQuantity",{{choices1,…}}] one among choices Restricted["StructuredQuantity",unit] convert to unit Restricted["StructuredQuantity",quantityvariable] restrict to units compatible with the physical quantity of quantityvariable Restricted["StructuredQuantity",unit,max] a quantity below Quantity[max,unit] Restricted["StructuredQuantity",unit,{min,max}] a quantity between Quantity[min,unit] and Quantity[max,unit] Restricted["StructuredQuantity",unit,{min,max,s}] a quantity between Quantity[min,unit] and Quantity[max,unit] with step s Restricted["StructuredQuantity",quantityvariable,max] a quantity below Quantity[max,unit], with unit the canonical unit of quantityvariable Restricted["StructuredQuantity",Automatic,Automatic,n] a quantity whose magnitude has n-digit precision - The bounds min and max and step s can also be expressed as quantities.
Options
- The following options can be used for the quantity magnitude:
-
DigitBlock Infinity number 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
Interpretation
- "StructuredQuantity" yields a Quantity.
Examples
Basic Examples (3)
Interpreter["StructuredQuantity"]["1.5 Hours"]Interpreter["StructuredQuantity"]["4.5e2 Meters"]Restrict and convert to a unit:
Interpreter[Restricted["StructuredQuantity", "Kilograms"]]["10 Ounces"]Accept unitless inputs in the presence of an appropriate restriction:
Interpreter[Restricted["StructuredQuantity", QuantityVariable["Money"]]]["100"]Interpreter[Restricted["StructuredQuantity", "Hours"]]["5.4"]No connection to the Wolfram Cloud is attempted. Only canonical units (as found in the InputForm) can be used:
Interpreter["StructuredQuantity"]["2 hr"]For currency units, the unit conversion is kept symbolical to avoid connecting to the Wolfram Cloud to get the exchange rate:
Interpreter[Restricted["StructuredQuantity", "USDollars"]]["12 Euros"]Interpreter[Restricted["StructuredQuantity", "Kilometers", {1, 100}]]["20 Miles"]Interpreter[Restricted["StructuredQuantity", Automatic, Automatic, 3]]["1.2345 Seconds"]Interpreter["StructuredQuantity", NumberSeparator -> ","]["18,726 Meters"]Related Guides
History
Introduced in 2014 (10.0)