Internet Arduino Integer
Internet Arduino Integer
Reference > Language > Variables > Data types > Int
int
[Data Types]
Description
On the Arduino Uno (and other ATmega based boards) an int stores a 16-bit (2-byte)
value. This yields a range of -32,768 to 32,767 (minimum value of -2^15 and a
maximum value of (2^15) - 1). On the Arduino Due and SAMD based boards (like
MKR1000 and Zero), 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
LANGUAGE
(2^31) - 1).
FUNCTIONS
int’s store negative numbers with a technique called (2’s complement math). The
VARIABLES 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.
STRUCTURE
The Arduino takes care of dealing with negative numbers for you, so that arithmetic
LIBRARIES
operations work transparently in the expected manner. There can be an unexpected
GLOSSARY complication in dealing with the bitshift right operator (>>) however.
EDIT THIS PAGE This code creates an integer called 'countUp', which is initially set as the number 0
(zero). The variable goes up by 1 (one) each loop, being displayed on the serial
monitor.
void setup() {
Serial.begin(9600); // use the serial port to print the number
}
void loop() {
countUp++; //Adds 1 to the countUp int on every loop
Serial.println(countUp); // prints out the current state of countUp
delay(1000);
}
https://www.arduino.cc/reference/en/language/variables/data-types/int/ 1/3
5.6.2019 Arduino Reference
See also
LANGUAGE String()
LANGUAGE array
LANGUAGE bool
LANGUAGE boolean
LANGUAGE byte
LANGUAGE char
LANGUAGE double
LANGUAGE float
LANGUAGE long
LANGUAGE short
LANGUAGE size_t
LANGUAGE string
LANGUAGE unsigned char
LANGUAGE unsigned int
LANGUAGE unsigned long
LANGUAGE void
LANGUAGE word
LANGUAGE Integer Constants
https://www.arduino.cc/reference/en/language/variables/data-types/int/ 2/3
5.6.2019 Arduino Reference
NEWSLETTER
https://www.arduino.cc/reference/en/language/variables/data-types/int/ 3/3