O'Reilly logo

Mastering Arduino by Jon Hoffman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Integer

The integer is the primary data type used to store numerical data when a decimal value is not needed. A variable of the integer type can contain numbers ranging from -32,768 to 32,768. An integer is defined using the int keyword.

We can declare an integer to be unsigned by using the unsigned keyword. An unsigned integer can range from 0 to 65,535 whereas the normal integer has a range of -32,768 to 32,768. The following code shows how we would define both a regular integer and an unsigned integer:

int mySignedInt = 25;
unsigned int myUnsignedInt = 15;

In the preceding code, we declared a variable named mySignedInt of the integer type with an initial value of 25. We also declared a second variable named myUnsignedInt of the unsigned ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required