Integers are your primary data-type for number storage.

On the 86Duino, an int stores a 32-bit (4-byte) value. This yields a range of -2,147,483,648 to 2,147,483,647 (minimum value of -2^31 and a maximum value of (2^31) – 1).

int‘s store negative numbers with a technique called 2’s complement math. The highest bit, sometimes referred to as the “sign” bit, flags the number as a negative number. The rest of the bits are inverted and 1 is added.

The 86Duino takes care of dealing with negative numbers for you, so that arithmetic operations work transparently in the expected manner. There can be an unexpected complication in dealing with the bitshift right operator (>>) however.


int ledPin = 13;


int var = val;

var – your int variable name
val – the value you assign to that variable

Coding Tip

When variables are made to exceed their maximum capacity they “roll over” back to their minimum capacity, note that this happens in both directions. Example for a 32-bit int:

   int x;
   x = -2147483648;
   x = x - 1;       // x now contains 2,147,483,647 - rolls over in neg. direction

   x = 2147483647;
   x = x + 1;       // x now contains -2,147,483,648 - rolls over

See also

unsigned int
unsigned long
Integer Constants
Variable Declaration

Language Reference Home

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.