Posted on

What is a real in Pascal? Simple And Easy!

What is a real in Pascal? A real is another basic data type of Object Pascal. It’s main purpose is to store values inside the Computer as an approximation of a Real number. As real numbers are infinite the computer is unable to represent them. Most of the time the computer will use some other method. Such as using rational expressions to represent Real Numbers. Let’s discuss more below!

Usage Of Real Data Type

The Real Data Type is a powerful data type and kind of a stronger version of the Integer and Float data types. Real can hold can store both Integer and Floating point values. Now here i catch you a bit off guard on the part where i said floating point values. Allow me to explain, A floating point is yet another data type of Pascal.

I’ll go into more detail on it in another post for now keep the basic definiton in mind which is as follows:

A floating point is a data type that can store numbers with decimal places or fractions. A real data type is a powerful data type. It can store whole numbers, real numbers and floating point numbers.

Why Use Integer And Floats If Real Is A Thing???

The computer allocates a specific amount of memory for all data types. For example, Take a Floating point as an example. A float can store decimal numbers as well as whole numbers. As mentioned above it can store decimal numbers. Hence the computer allocates more memory to it as compared to the memory it gives to Integers.

As such using Real or Floats as replacements may cause the computer to use excess memory. Causing significant lag. It may make your entire software crash or worse.

That about explains this i hope. I’ll dedicate a whole post regarding Error finding. And more! So worry not if not now then later you will definetly understand!

Example time!

Example Of Real Data Type

Unlike previous posts the Real data type is rather simple. It is almost the same thing as a integer or a floating point value. Instead a simple example can be something like say “3.4” Or 7/8 and so on. It’s the exact same thing as a integer and float combined.

Keep in mind the warning i gave above. Using wrong data types for what they are not meant for will not assist you. Rather it will slow down your progress most of the time.

I recommend watching this short video. From the SchoolFreeWare Youtube to advance your understanding on the subject.