Menu

1 / 2

Integers and Floating-Point Numbers in C++

DEV Community: cpp·Tomáš Svojanovský·6 months ago
#VC7PkJeq
#dev#include#integer#enter#exit
Reading 0:00
15s threshold

File Extensions in C++

Before we start writing code, it is worth mentioning that C++ source files can use different file extensions.

Common C++ file extensions include:

. cc . cpp . cxx

Enter fullscreen mode

Exit fullscreen mode

All three are valid for C++ source files.

In practice, .cpp and .cc are probably the most common ones. The .cxx extension is also valid, but you will usually see it less often.

For this example, let’s imagine we create a file called:

integers_floats.cpp

Integer Types in C++

An integer is a whole number without a fractional part.

Examples of integers are:

0 42 -10 100000

Enter fullscreen mode

Exit fullscreen mode

In C++, integers can be either:

signed unsigned

Enter fullscreen mode

Exit fullscreen mode

A signed integer can store both negative and positive values.

An unsigned integer can store only zero and positive values.

For example:

- 10 // signed 0 // signed or unsigned 42 // signed or unsigned

Enter fullscreen mode

Exit fullscreen mode

Fixed-Width…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.