Skip to content

NumberQ ​

True only for an explicit numeric literal — a symbolic constant like Pi is NOT NumberQ.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageNumberQ!
NumberQ(expr)True for an Integer/Real/Rational/Complex literal, False otherwise
Typed signatures
TypePackageApplies
(any) -> booleancombinatoricsalways

Domain: Collections

Details
  • Unlike compute-engine's own isNumber (True for Pi, GoldenRatio, …), NumberQ(Pi) is False — Wolfram's own distinction, kernel-checked (NumberQ[Pi] is False, NumberQ[N[Pi]] is True).

Examples

Basic #
live ↗
InNumberQ(2)\mathrm{NumberQ}(2)OutTrue\mathrm{True}
Scope #
live ↗
InNumberQ(π)\mathrm{NumberQ}(π)OutFalse\mathrm{False}
live ↗
InNumberQ(x)\mathrm{NumberQ}(x)OutFalse\mathrm{False}

A numerically evaluated constant is a number

live ↗
InNumberQ(N(2))\mathrm{NumberQ}(N(\sqrt{2}))OutTrue\mathrm{True}

Undefined symbols are not numbers

live ↗
In[NumberQ(c),NumberQ(d)]\bigl\lbrack\mathrm{NumberQ}(c), \mathrm{NumberQ}(d)\bigr\rbrackOut[False,False]\bigl\lbrack\mathrm{False}, \mathrm{False}\bigr\rbrack

Two more unknown symbols, both False

live ↗
In[NumberQ(o),NumberQ(u)]\bigl\lbrack\mathrm{NumberQ}(o), \mathrm{NumberQ}(u)\bigr\rbrackOut[False,False]\bigl\lbrack\mathrm{False}, \mathrm{False}\bigr\rbrack
live ↗
InNumberQ(2)\mathrm{NumberQ}(\sqrt{2})OutTrue\mathrm{True}
live ↗
InNumberQ(∞)\mathrm{NumberQ}(∞)OutTrue\mathrm{True}
About
Examples8
Checked againstWolfram Language 6 agree2 differ
CrosswalkWolfram Language

See also: ReIm