KnownUnitQ[expr]
returns True if expr is a canonical unit, and False otherwise.
KnownUnitQ[expr,dims]
gives True if expr is a canonical unit with physical dimensions dims, and False otherwise.
KnownUnitQ
KnownUnitQ[expr]
returns True if expr is a canonical unit, and False otherwise.
KnownUnitQ[expr,dims]
gives True if expr is a canonical unit with physical dimensions dims, and False otherwise.
Details
- KnownUnitQ has attribute HoldFirst.
- KnownUnitQ[expr,dims] returns True if expr is a canonical unit and is compatible with dims.
- Dimensional specification dims may be a list of unit dimensions, a QuantityVariable, a Quantity or a string representing a quantity variable or unit dimension.
Examples
open all close allBasic Examples (2)
Test whether an input expression is a canonical unit:
KnownUnitQ["Feet"]KnownUnitQ["Feet" ^ 2 / "Farads"]KnownUnitQ["Foo"]Test if an expression is a time unit:
KnownUnitQ["Seconds", "Time"]KnownUnitQ["Meters", "Time"]Scope (9)
Units represented by a single string:
KnownUnitQ["Meters"]KnownUnitQ["Siemens"]KnownUnitQ["Newtons" * "Meters"]KnownUnitQ["Watts" / "Meters" ^ 2]KnownUnitQ returns True for valid IndependentUnit specifications:
KnownUnitQ[IndependentUnit["myUnit"]]KnownUnitQ[IndependentUnit["Unit1"] / IndependentUnit["Unit2"] ^ 3]It returns False for invalid IndependentUnit specifications:
KnownUnitQ[IndependentUnit[1]]KnownUnitQ[IndependentUnit[unit]]MixedUnit specifications of compatible units:
KnownUnitQ[MixedUnit[{"Yards", "Centimeters"}]]Incompatible units do not produce a valid MixedUnit specification:
KnownUnitQ[MixedUnit[{"Seconds", "Centimeters"}]]DatedUnit specifications:
KnownUnitQ[DatedUnit["USDollars", 1990]]KnownUnitQ[DatedUnit["Euros", Today]]Prefixes are dimensionless known units:
KnownUnitQ["Centi"]KnownUnitQ["Mega"]Dimension specifications may be a list of unit dimensions, QuantityVariable, Quantity or string:
KnownUnitQ["Meters", {{"LengthUnit", 1}}]KnownUnitQ["Meters", Height]KnownUnitQ["Meters", Quantity[10, "Feet"]]KnownUnitQ["Meters", "LengthUnit"]KnownUnitQ["Meters", "Depth"]KnownUnitQ returns False if the first argument is not a canonical unit expression:
KnownUnitQ[x, Acceleration]KnownUnitQ returns False if the second argument is not a recognized dimension specification:
KnownUnitQ["Meters" / "Seconds", "foo"]KnownUnitQ["Meters" / "Seconds", x]Properties & Relations (2)
KnownUnitQ has attribute HoldAll:
x = "Meters"KnownUnitQ[x]KnownUnitQ["Meters" / "Meters"]A MixedUnit specification is valid if it contains compatible units:
KnownUnitQ[MixedUnit[{"Centimeters", "Meters", "Feet"}]]CompatibleUnitQ[{"Centimeters", "Meters", "Feet"}]Possible Issues (2)
Quantity can interpret a non-canonical unit, converting it to its canonical form:
Quantity[1, "ft"]InputForm[%]KnownUnitQ does not accept non-canonical units:
KnownUnitQ["ft"]But it does accept their canonical form:
KnownUnitQ["Feet"]Dimension specifications may not be a unit:
KnownUnitQ["Feet", "Meters"]Tech Notes
Related Guides
Text
Wolfram Research (2012), KnownUnitQ, Wolfram Language function, https://reference.wolfram.com/language/ref/KnownUnitQ.html (updated 2024).
CMS
Wolfram Language. 2012. "KnownUnitQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/KnownUnitQ.html.
APA
Wolfram Language. (2012). KnownUnitQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/KnownUnitQ.html
BibTeX
@misc{reference.wolfram_2026_knownunitq, author="Wolfram Research", title="{KnownUnitQ}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/KnownUnitQ.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_knownunitq, organization={Wolfram Research}, title={KnownUnitQ}, year={2024}, url={https://reference.wolfram.com/language/ref/KnownUnitQ.html}, note=[Accessed: 13-June-2026]}