MachineNumberQ¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
MachineNumberQ[expr] gives True if expr is a machine-precision real or complex number, and False otherwise.
Examples¶
All examples below are verified against the current Mathilda build.
In[1]:= MachineNumberQ[Sin[1000.]]
Out[1]= True
In[2]:= MachineNumberQ[Exp[1000.]] (* overflows to +inf *)
Out[2]= False
In[3]:= MachineNumberQ[-29037945.290347]
Out[3]= True
In[4]:= MachineNumberQ[N[Pi, 30]] (* MPFR, not machine *)
Out[4]= False
In[5]:= MachineNumberQ[1.0 + 2.0 I]
Out[5]= True
In[6]:= MachineNumberQ[1 + 2 I] (* exact Gaussian integer *)
Out[6]= False
Implementation notes¶
builtin_machinenumberq (src/numeric.c) returns True when the argument is a finite EXPR_REAL (via is_machine_real_leaf, which checks EXPR_REAL and isfinite), or a Complex whose real and imaginary parts are both finite machine reals; otherwise False. Exact integers/rationals and arbitrary-precision EXPR_MPFR values are not machine numbers.
Attributes: Protected.
Implementation status¶
Stable — documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
References¶
- Source:
src/numeric.c - Specification:
docs/spec/builtins/expression-information.md