Function Repository Resource:

MachineIntegerQ

Source Notebook

Check if a number falls into the range of machine-sized integers for your computer

Contributed by: Wolfram Research

ResourceFunction["MachineIntegerQ"][expr]

returns True if expr corresponds to a machine‐sized integer, and False otherwise.

Details and Options

On a typical computer system, machine‐sized integers must lie in the range -231+1 to +231-1 or -263+1 to +263-1.
Results from the Wolfram Language are not affected by whether an integer is machine sized or not; the speed of operations may, however, be affected.

Examples

Basic Examples (3) 

Check whether numbers are machine integers or not:

In[1]:=
ResourceFunction["MachineIntegerQ"][1]
Out[1]=
In[2]:=
ResourceFunction["MachineIntegerQ"][1.]
Out[2]=

The largest machine integer on this machine:

In[3]:=
2^63 - 1
Out[3]=
In[4]:=
ResourceFunction["MachineIntegerQ"][%]
Out[4]=

The next integer is not a machine integer:

In[5]:=
%% + 1
Out[5]=
In[6]:=
ResourceFunction["MachineIntegerQ"][%]
Out[6]=

The smallest machine integer on this machine:

In[7]:=
-2^63 + 1
Out[7]=
In[8]:=
ResourceFunction["MachineIntegerQ"][%]
Out[8]=

The preceding integer is not a machine integer:

In[9]:=
%% - 1
Out[9]=
In[10]:=
ResourceFunction["MachineIntegerQ"][%]
Out[10]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 25 February 2019

License Information