Arduino Variables

Table of contents

  1. Bits and Bytes
  2. Integers
    1. int and long
    2. Unsigned integer types
    3. Integer arithmetic
  3. Floating point
    1. Floating point arithmetic
  4. Lecture notes and exercises from ME 120

Bits and Bytes

Humans usually think in decimal (base 10) values when counting.

Binary (base 2) values are at the core of all programming languages and hardware implementations.

  • A bit is a binary digit, either a 1 or a 0 (zero).
  • A byte is a group of 8 bits.

Integers

int and long

An int is an integer (usually) stored with 16 bits. The range of values stored in a (16 bit) int is -32768 to 32767.

A long is an integer (usually) stored with 32 bits

Unsigned integer types

Integer arithmetic

Floating point

Floating point arithmetic

Lecture notes and exercises from ME 120