Message Boards Message Boards

0
|
3952 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Assess whether a number is Real?

Posted 7 years ago

good morning, how can I assess whether a number is Real and that does not return a result of "Infinity Complex, ... etc ..." I have to run the statement thousands of times, this I have written is extremely slow

a={1/0};
xEval[a_] := If[Count[{"Infinity", "Indeterminate", "ComplexInfinity", "Overflow[]", "Underflow[]"}, ToString[Quiet[a]]] == 0 && Element[a, Reals], True, False];
POSTED BY: Paolo Pellegrini
2 Replies

or

NumericQ[a]

to test if its a number?

POSTED BY: Neil Singer

Is the function Head[] what you need?

In[1]:= Head[1]

Out[1]= Integer

In[2]:= Head[1.2]

Out[2]= Real

In[3]:= Head[1/2]

Out[3]= Rational

In[4]:= Head[1 + 2 I]

Out[4]= Complex
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract