C++ Tutorial II – Float vs. Int

1 minute read

You may be wondering what is a Float and why it has certain uses that Int cannot handle. All will be explained concisely so you can go back to whatever you do when you’re not at ByteRevel.

What is a Float?

A float stands for Floating Point. It is just a random point in space that has a certain value. Its main use is to define non-integral numbers. So it can be used with fractions.

What is an Int?

Int is the variable used to show numbers or letters that are integers. Since letters and words are not numeric, ints can handle them. But using Int cannot show fractions and decimals because they are not INTEGERS!!!!

Float vs. Int

Why not we just use floats? They can handle what ints can’t and what ints can. Well, using a float takes up more memory in a program. A normal float uses 4 bytes of memory in a computer while the extended form of a float, called a Double Float, takes up 8 bytes. Ints on the other hand use a range of 2 bytes to 4 bytes (on average) from a CPU.

Which to Use?

It all depends on your situation. If you are a budding programmer who wants to learn a new language, or you are interested in just learning C++ for the fun of it, its use is only defined by the size of the number (and if it is integral or not) you are using. The arithmetic behind using a Float or Int can get quite complicated and may require more than a website tutorial to understand. :)

Leave a Comment