C++ Builder Tutorials

C++ number types

C++ is a strongly typed language. That means, that every variable must be declared and that the compiler will check the type of all the variables before the compilation of your program. Without this feature, many errors would only appear at run-time, making them much harder to debug.

A simple example:
   int i;
   i = 0.5;
...results in an error message: Incompatible types: 'integer' and 'float'

In C++, there are 2 groups of numbers:

  • integer numbers
  • floating point numbers (have a decimal fraction)

Type Range
Integer types
   short int
   unsigned int
Floating point types
-2,147,483,648 to 2,147,483,647
-32,768 to 32,767
0 to 4,294,967,295
7 significant digits, exponent -38 to 38
15 significant digits, exponent -308 to 308