Bookmark and Share

There are two Mathematica boolean test functions about numbers or numeric objects: NumberQ and NumericQ. In Mathematica there are expressions that are numeric but not not numbers.

In[2]:= Prepend[{InputForm[#],NumberQ[#],NumericQ[#]}&/@{1,1.1,Pi,E,3/4,Sqrt[2]},{x,"NumberQ[x]","NumericQ[x]"}]//TableForm
Out[2]//TableForm=
x   NumberQ[x]  NumericQ[x]
1   True    True
3/4 True    True
1.1 True    True
Sqrt[2] False   True
Pi  False   True
E   False   True

If the object involves Unevaluated and Hold, it can be a little more subtle

NumericQ[Unevaluated[1 + 1]] 
Out[33]= False 
blog comments powered by Disqus