# 4.1 — Introduction to fundamental data types

Bits, bytes, and memory addressing

In lesson 1.3 -- Introduction to variables, we talked about the fact that variables are names for a piece of memory that can be used to store information. To recap briefly, computers have random access memory (RAM) that is available for programs to use. When a variable is defined, a piece of that memory is set aside for that variable.

The smallest unit of memory is a binary digit (also called a bit), which can hold a value of 0 or 1. You can think of a bit as being like a traditional light switch -- either the light is off (0), or it is on (1). There is no in-between. If you were to look at a random segment of memory, all you would see is …011010100101010… or some combination thereof.

Memory is organized into sequential units called memory addresses (or addresses for short). Similar to how a street address can be used to find a given house on a street, the memory address allows us to find and access the contents of memory at a particular location.

Perhaps surprisingly, in modern computer architectures, each bit does not get its own unique memory address. This is because the number of memory addresses are limited, and the need to access data bit-by-bit is rare. Instead, each memory address holds 1 byte of data. A byte is a group of bits that are operated on as a unit. The modern standard is that a byte is comprised of 8 sequential bits.

Key insight

In C++, we typically work with “byte-sized” chunks of data.

The following picture shows some sequential memory addresses, along with the corresponding byte of data:

As an aside...

Some older or non-standard machines may have bytes of a different size (from 1 to 48 bits) -- however, we generally need not worry about these, as the modern de-facto standard is that a byte is 8 bits. For these tutorials, we’ll assume a byte is 8 bits.

Data types

Because all data on a computer is just a sequence of bits, we use a data type (often called a “type” for short) to tell the compiler how to interpret the contents of memory in some meaningful way. You have already seen one example of a data type: the integer. When we declare a variable as an integer, we are telling the compiler “the piece of memory that this variable uses is going to be interpreted as a non-fractional number”.

When you assign a value to an object, the compiler and CPU take care of encoding your value into the appropriate sequence of bits for that data type. When you ask for your value back, your number is “reconstituted” from the sequence of bits in memory.

As an example, when you give an integer object the value 65, that value is stored in memory as the sequence of bits `0100 0001`. When you need that value, those bits are reconstituted back into the integer value 65.

Fortunately, the compiler and CPU take care of converting values into bit sequences (and reconstructing those values from bit sequences again when needed), so you don’t need to worry about that part. All you need to do is pick a data type for your object that best matches your desired use.

Fundamental data types

C++ comes with built-in support for many different data types. These are called fundamental data types, but are often informally called basic types, primitive types, or built-in types.

Here is a list of the fundamental data types, some of which you have already seen:

Types Category Meaning Example
float
double
long double
Floating Point a number with a fractional part 3.14159
bool Integral (Boolean) true or false true
char
wchar_t
char8_t (C++20)
char16_t (C++11)
char32_t (C++11)
Integral (Character) a single character of text ‘c’
short
int
long
long long (C++11)
Integral (Integer) positive and negative whole numbers, including 0 64
std::nullptr_t (C++11) Null Pointer a null pointer nullptr
void Void no type n/a

This chapter is dedicated to exploring these fundamental data types in detail (except std::nullptr_t, which we’ll discuss when we talk about pointers). C++ also supports a number of other more complex types, called compound types. We’ll explore compound types in a future chapter.

Author's note

The terms “integer” and “integral” are similar, but have different meanings. Integers are positive and negative whole numbers, including 0. The term “integral types” (which means “like an integer”) includes all of the boolean, characters, and integer types (and thus is a bit broader in definition). Integral types are named so because they are stored in memory as integers, even though they behave slightly differently.

The _t suffix

Many of the types defined in newer versions of C++ (e.g. std::nullptr_t) use a _t suffix. This suffix means “type”, and it’s a common nomenclature applied to modern types.

If you see something with a _t suffix, it’s probably a type. But many types don’t have a _t suffix, so this isn’t consistently applied.

 4.2 -- Void Index 3.x -- Chapter 3 summary and quiz

### 74 comments to 4.1 — Introduction to fundamental data types

• imiltsiass

[b]<a href="http://www.tiffany1837outlet.com/"tiffany jewelry
tiffany & co

• imiltsiass

in, spooky morning, snap-apple nighttime, costume day/da de los disfrazes, along with pooky overnight, Halloween is actually popular in numerous western international locations, including the us, ireland, scotland, wales, great britain, canada, often australia as well as new zealand.In recent years, glow stands & directed glow products are getting to be very well known during Halloween parties celebrations.Young children use Halloween night glow stays and brought about glow programs during day celebrations.in, spooky morning, snap-apple nighttime, costume day/da de los disfrazes, along with pooky overnight, Halloween is actually popular in numerous western international locations, including the us, ireland, scotland, wales, great britain, canada, often australia as well as new zealand.In recent years, glow stands & directed glow products are getting to be very well known during Halloween parties celebrations.Young children use Halloween night glow stays and brought about glow programs during day celebrations.The terrifying glow at nighttime Halloween sparkle products assistance kids a great deal out on trick as well as treating after dark and currently have great excitement.Halloween shine products usually are not just for the purpose of fun together with scaring rather and also they keep young ones safe along with visible once they are outside in dreary.Halloween gleam sticks, brought about flash stays, glow jewelry, glow wristbands, glow headwears or anything else, make any occasion delightful.The thing about these kind of glow programs is that they can be extremely reliable and low-priced.You enables your little ones to play just read the simple products without the need of worrying around anything.You can get these shine products inside bulk on-line.These products can be bought in bulk on-line.You may also get affordable glow services and inexpensive glow products and services online.If you would like some high-quality glow solutions online, visit this glow house that promises lots of quality sparkle products.

• t have fantastic discount offers for his or her customers.Many of these websites additionally offer membership in case you travel lots and would wish to hear about the latest promotions and cut price packages.These sites plus the people just who run these are often known as online consolidators and you may contact these products anytime in order to ask queries and learn about the best and newest trends with airfares.
Once you've short-listed a number of sites, the next matter to do is usually to observe them a couple of days to determine what spot locations are the best ones to get discount airfares and consider some of the days for airfares proceed down.You may notice a typical pattern in the good and the bad of airfares.Note that down to see when typically the tickets could be the cheapest for just a particular location.
Exactly like certain a short time are cheaper than other people, some seasons may also be cheaper than others.Remember thatt have fantastic discount offers for his or her customers.Many of these websites additionally offer membership in case you travel lots and would wish to hear about the latest promotions and cut price packages.These sites plus the people just who run these are often known as online consolidators and you may contact these products anytime in order to ask queries and learn about the best and newest trends with airfares.

Once you've short-listed a number of sites, the next matter to do is usually to observe them a couple of days to determine what spot locations are the best ones to get discount airfares and consider some of the days for airfares proceed down.You may notice a typical pattern in the good and the bad of airfares.Note that down to see when typically the tickets could be the cheapest for just a particular location.

Exactly like certain a short time are cheaper than other people, some seasons may also be cheaper than others.Remember that in case you are planning to waste this Christmas somewhere else, then booking for the flight way earlier would be the ultimate way to go.It is strongly recommended that people book not less than four months prior to a flight.Similarly summer could be the peak period when people opt for vacations scattered cooler than their city.Now of 12 months is additionally expensive for the purpose of air drivers.But needless to say there are consolidators that will book you upfront for any cheaper air travel.

Last-minute deals may also be of particular desire for this class.Many websites will provide you with information around the last-minute savings that certain airlines have to offer to sell off off his or her's extra seats.But most of these deals are certainly not available for everyone destinations.You will need to either bide time until your location to be listed on one of them offers or acquire some various option.Although last-minute reservation should come very cheap often (even 70% discount emerges by certain airlines), but there're useful only should you be traveling on your own or you have lots of time on your hands.

Early-morning airfares are generally cheaper compared to the rest.In the same way, flying over a Friday and ever coming back on Tuesday morning happen to be cheaper compared to flying for a Saturday and re-occurring on Weekend evening.You will need to plan your own trip so and come up with some changes to adjust to this kind of schedule, but not surprisingly it could save you significant amounts of money since weekend airfares are now and again sky-high, particularly if the position is favorite.

They're only limited strategies to finding low cost airfare online.Once you are actually there you will see out significant amounts of information all by yourself.So usually do not waste time, just log online and inevitably be an airliner that games your schedule plus your budget.

• perfectperfect
• kijonrwslows

• imiltsiass

l wedding, you will want to have that sized to guarantee the fit is ideal as nicely.
In the case of sizing being married ring, former mate a minimal tricky.You will also schedule plenty of to alter the measurements if required.The following certainly are a few tips you must follow to receive the most suitable fit an individual's ring.
The greatest situation designed for sizing your wedding band is so that the air flow is comfortable on temperature and additionally climate.Any varieties rather also hot or perhaps too freezing could improve or lessen your actual band size.It is actually suggested you do not size the wedding ceremony ring directly after invest in.The call needs time to l wedding, you will want to have that sized to guarantee the fit is ideal as nicely.

In the case of sizing being married ring, former mate a minimal tricky.You will also schedule plenty of to alter the measurements if required.The following certainly are a few tips you must follow to receive the most suitable fit an individual's ring.

The greatest situation designed for sizing your wedding band is so that the air flow is comfortable on temperature and additionally climate.Any varieties rather also hot or perhaps too freezing could improve or lessen your actual band size.It is actually suggested you do not size the wedding ceremony ring directly after invest in.The call needs time to sit in your little finger; many people realize sizing will not be necessary just after wearing it just the summer days.High temperature, climate, and actions all see how well the actual ring might fit your finger.

If for example the ring you'd like must end up being sized, youre able to determine the ring size at your area jewelry shop, purchasing an important ring sizer, or even getting a string at your house.

You're able to measure your own private finger regarding ring dimensions, however, it is far better if an individual leave it to somewhat of a professional.The thread technique isn't really always precise, therefore, dont want to be observed upon.Jewelers most often have their personal trained individuals and professional ring sizers to start this for you will.This will always obtain the ideal size to your wedding engagement ring.After every, the perfect a wedding ring is not too perfect if it doesn't stop here fit.

It's always ultimately important that your ring sizer suit comfortably on your finger, previously authorizing the actual jeweler to build your a wedding ring of that size.Have the fitting call will keep your ring do not fall off of or damage your fingers because the device is far too tight.Subsequently after proper sizes, the ring you have opted will end up completely perfect and that you will feel self-assured in sporting in and in the choice.

• ordwaneffshuff

look for contacts low-priced online.You will likely get numerous hits, but a minimum of you'll have a starting factor.Visit websites, see what you should need to be able to place plus order, and keep an eye on what you discover.Eventually, you are able to narrow the selections right down to the preferred site feasible.
Another method to find contacts cheap on the internet is through person to person.Talk for your friends who have contacts and see where they find them.Additionally, talk to members of the family and focus on what you actually hear peolook for contacts low-priced online.You will likely get numerous hits, but a minimum of you'll have a starting factor.Visit websites, see what you should need to be able to place plus order, and keep an eye on what you discover.Eventually, you are able to narrow the selections right down to the preferred site feasible.

Another method to find contacts cheap on the internet is through person to person.Talk for your friends who have contacts and see where they find them.Additionally, talk to members of the family and focus on what you actually hear people say.Looking to other people for this sort of information can be quite valuable because they have made use of the services and know if it's worth your time and effort and finances.When you do it yourself, on another hand, you are doing a little learning from mistakes no matter how much online research you need to do.

Lastly, you will find contact accessories cheap on the internet by looking to consumer web-sites.There are numerous websites out there that complete consumer homework on almost any retail purchase it's possible you'll make.They will help you to find the sites by yourself, but so that you can still have another person tell you if the site is effective or definitely not.Common Feeling always prevails here.

Vision treatment and correction can certainly be pricey.Nevertheless, finding contact lenses cheap online can really help to counteract that fee.There are numerous ways to seek out online contact lenses, but using the tips in this case you will be able to get a good start on the process.Once you need to do, though, you will likely never buy contacts every other way once again.?

• rameye

Hey Alex your comment board is being hijacked by spammers.