NumberQ
Examples
open all close allBasic Examples (1)
NumberQ tests whether an object is explicitly a number:
NumberQ[5.6]NumberQ[x]Scope (3)
The expression must be manifestly a number:
NumberQ[Sqrt[2]]You can test if a quantity represents a number with NumericQ:
NumericQ[Sqrt[2]]On numerical coercion with N, such quantities generally become numbers:
NumberQ[N[Sqrt[2]]]NumberQ[Infinity] gives False:
NumberQ[Infinity]The same is true for complex and directed infinities:
{c, d} = {(1 + I) / 0, Infinity * (1 + I)}{NumberQ[c], NumberQ[d]}NumberQ[Overflow[]] and NumberQ[Underflow[]] give True:
{o, u} = {$MaxNumber * 2, $MinNumber / 2}{NumberQ[o], NumberQ[u]}They are both treated as Real:
{Head[o], Head[u]}Applications (2)
Test if a matrix consists entirely of numbers:
m = {{1, 2 / 3}, {4., 5 + 6I}};MatrixQ[m, NumberQ]Define a function that only evaluates when the argument is a number:
f[xp0_ ? NumberQ] := Block[{x, t}, First[x[10] /. NDSolve[{x''[t] + Sin[x[t]] == 0, x[0] == 0, x'[0] == xp0}, x, {t, 0, 10}]]]It does not evaluate with a symbolic argument:
f[xp0]It does evaluate when the argument is a number:
Plot[f[xp0], {xp0, 0, 2}]Use FindRoot to find all the solutions of the boundary value problem with
:
xps = xp0 /. {FindRoot[f[xp0], {xp0, .5, 1}], FindRoot[f[xp0], {xp0, 1., 1.9}], FindRoot[f[xp0], {xp0, 1.9, 2.}]}sols = Table[First[x[t] /. NDSolve[{x''[t] + Sin[x[t]] == 0, x[0] == 0, x'[0] == xp0}, x, {t, 0, 10}]], {xp0, xps}]Plot[sols, {t, 0, 10}]Properties & Relations (3)
NumberQ is equivalent to MatchQ[#,_Integer|_Rational|_Real|_Complex]&:
TableForm[Table[{x, NumberQ[x], MatchQ[#, _Integer | _Rational | _Real | _Complex]&[x]}, {x, {1, 3 / 2, 1.5, 1 + I, E, Sin[1], Underflow[], Overflow[], Infinity}}], TableHeadings -> {{}, {"x", "NumberQ", "match"}}]Use RealValuedNumberQ to exclude complex numbers:
RealValuedNumberQ /@ {1, 3 / 2, 1.5, 1 + I}If NumberQ[x] is True, then NumericQ[x] is also True:
TableForm[Table[{x, NumberQ[x], NumericQ[x]}, {x, {1, 3 / 2, 1.5, 1 + I, E, Sin[1], Underflow[], Overflow[], Infinity}}], TableHeadings -> {{}, {"x", "NumberQ", "NumericQ"}}]Tech Notes
Related Guides
History
Introduced in 1988 (1.0) | Updated in 1996 (3.0)
Text
Wolfram Research (1988), NumberQ, Wolfram Language function, https://reference.wolfram.com/language/ref/NumberQ.html (updated 1996).
CMS
Wolfram Language. 1988. "NumberQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 1996. https://reference.wolfram.com/language/ref/NumberQ.html.
APA
Wolfram Language. (1988). NumberQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NumberQ.html
BibTeX
@misc{reference.wolfram_2026_numberq, author="Wolfram Research", title="{NumberQ}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/NumberQ.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_numberq, organization={Wolfram Research}, title={NumberQ}, year={1996}, url={https://reference.wolfram.com/language/ref/NumberQ.html}, note=[Accessed: 12-June-2026]}