NumberQ

NumberQ[expr]

gives True if expr is a number, and False otherwise.

Details

Examples

open allclose all

Basic Examples  (1)

NumberQ tests whether an object is explicitly a number:

Scope  (3)

The expression must be manifestly a number:

You can test if a quantity represents a number with NumericQ:

On numerical coercion with N, such quantities generally become numbers:

NumberQ[Infinity] gives False:

The same is true for complex and directed infinities:

NumberQ[Overflow[]] and NumberQ[Underflow[]] give True:

They are both treated as Real:

Applications  (2)

Test if a matrix consists entirely of numbers:

Define a function that only evaluates when the argument is a number:

It does not evaluate with a symbolic argument:

It does evaluate when the argument is a number:

Use FindRoot to find all the solutions of the boundary value problem with :

Plot the solutions:

Properties & Relations  (2)

NumberQ is equivalent to MatchQ[#,_Integer|_Rational|_Real|_Complex]&:

If NumberQ[x] is True, then NumericQ[x] is also True:

Introduced in 1988
 (1.0)
 |
Updated in 1996
 (3.0)