Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Tip

This page introduces the basics of programming using C/C++.

Visualiser la version française de cette page.

What is programming

Programming is the process of creating complex behaviour by giving simple instructions to a computer. It is the art of creating a program – a sequence of instruction which the computer should execute to achieve a specific task.

...

The code is written in, compiled and finally downloaded in the micro-controller using an Integrated Development Environment. Although the CRC Robotics Competition participants are free to use whatever Arduino compatible IDE, we strongly recommend (and only support) the official desktop-based Arduino IDE.

...

Info

In Arduino IDE, compiling is known as verifying and code is written in .ino files.

...

Computers can natively only perform operations on some data types. These are integer and floating point (float) numbers. Those are called primitives. Integers are further divided in two classes, signed and unsigned. Signed numbers can represent negative as well as positive integers (signed = with a sign, get it?), while unsigned numbers can’t.

Here is a summary chart:

Primitive

Can it represent decimal numbers (e.g. 0.1)?

Can it represent negative numbers (e.g. -2)?

Floats

Yes

Yes

Signed integers

No

Yes

Unsigned integers

No

No

While it could be tempting to always use floats, you should always strive to use the type that provides the least while providing what you need. By removing some possibilities, you can avoid small mistakes because of inattention. Computers are also generally faster with integers than with floats.

...

In a more understandable format:

Type

Also known as in Arduino

Negatives?

Size (bit)

Minimum

Maximum

uint8_t

unsigned char or byte

No

8

0

28 - 1 (255)

int8_t

char

Yes

8

-27 (-128)

27 - 1 (127)

uint16_t

unsigned int or word

No

16

0

216 - 1 (65 535)

int16_t

int

Yes

16

-215 (-32 768)

215 - 1 (32 767)

uint32_t

unsigned long

No

32

0

232 - 1 (4 294 967 295)

int32_t

long

Yes

32

-231 (-2 147 483 648)

231 - 1 (2 147 483 647)

uint64_t

unsigned long long

No

64

0

264 - 1 (3.68935 × 1019)

int64_t

long long

Yes

64

-263 (-9.22337 × 1018)

263 - 1 (9.22337 × 1018)

Info

When starting, you can use the “Also known as in Arduino” nomenclature, but you should try to understand and use the official integer nomenclature.

In the official nomenclature, the size of every int type is explicitely defined and the same on every platform, whereas an “int” might be 16bit on a micro-controller model and 32bit on another one. Using this nomenclature is a nice habit since it makes your code more portable; meaning that it will have the same execution characteristic on different platforms.

Related articles

Filter by label (Content by label)
sorttitle
excerptTyperich content
cqllabel = "ar-getting_started"