Float | Numerical Data Types
C++ Data Types

Зміст курсу

C++ Data Types

## C++ Data Types

1. Introduction
2. Numerical Data Types
3. Text Data Type
4. Other Data Types and Concepts

# Float

The numbers do not end with integers. There are also floating-point numbers. In C++, we use `float` and `double` data types to store them. This chapter will cover the `float` data type, while the next will address the `double` data type and its distinctions. Below is the syntax for the usage of `float`:

Let's take a quick look at how floating-point numbers are stored in memory.
The `float` data type takes up 4 bytes of memory, just like an `int`. However, converting such numbers to binary code is much trickier:

Here is an example of how `float num = 13.45` would be stored:

It is okay if you do not entirely understand what is happening here. The important thing to note is that the representation of a `float` is split into 3 parts:

As a result, `float` has a precision of 7 decimal digits and a range of 1.2e-38 to 3.4e+38 (applies to both negative and positive numbers). So most of the time, the range is not a problem. But precision sometimes is.

Все було зрозуміло?

Секція 2. Розділ 4
We're sorry to hear that something went wrong. What happened?