I am creating an alternative function of IntegerQ[]
function. Now I don't want any output. I just want my function to check whether this is integer or not. I'm gonna use it in another code. My code looks like;
IntQ[n_] := Block[{}, GP = 0;
{j = 0;
If[n >= 0,
For[i = n, i > 0, i--, j++],
For[i = (-n), i > 0, i--, j++]]};
{If[j == n, True, False]};
]
It is not working. I just want to know where is the problem, why the problem is causing and how to solve it?
Generally IntegerQ[6]
would return True as an output and in other function it wouldn't return anything but we can use that value actually. So that's where my problem is.
IntegerQ
is not sufficient for your problem. Might be an XY problem. $\endgroup$IntegerQ[]
which is not in the condition. That's why was trying to create an alternate. $\endgroup$IntegerQ
tests only whether theHead
of the expression equalsInteger
. There are other undocumented functions though that attempt to check an arbitrary number (e.g. finite precision numbers) for being integers, e.g.RandomProcesses`TemporalDataDump`iIntegerQ
. $\endgroup$IntegerQ
actually checks if something is internally held as an integer (I think). For example, this returnsFalse
:IntegerQ@Integer[f]
. $\endgroup$