3. Real

A 'Real' data type is numerical data which contains decimal numbers.

It would be used when extra detail is required and a whole number would not provide enough information.

Examples of where a 'real' data type is used can be seen below:

  • Weight in Kg

12.25, 19.99, 199.99

  • Room measurement in metres

14.5

  • Temperature (degrees Celsius)

37.5

Note that a 'real' data type cannot store the measurement symbol itself ($,£, %), nor the type of quantity being measured e.g. metres, Kilograms, Celsius. If you use this data type then you need to put the unit of measurement after the field name as we have done above.

Also note that currency can be either a 'real' or an 'integer' data type. For small amounts of currency then decimal places would probably be used, so you would use the 'real' data type. But for large amounts e.g. a car or house then it is unlikely that decimal places is of any interest (would you be interested to know that a car cost £4021.99 as opposed to £4022? - it would make more sense to use the 'integer' data type.

 

 

challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Real Data Type

 

Additional facts (not needed for syllabus)

FAQ: If the 'Real' data type can store any number, why bother with Integer?

Answer: Two things: Storage and Processing Speed

Storage: It take more memory to store a 'Real' number than an integer, so if all those decimal points are not relevant then it is just wasted space. The database would be larger, backups would be slower and so on.

Processing Speed: It takes longer for a computer to calculate with 'real' numbers than integer data types because it has to handle all those decimal points. So a developer trying to make a really fast system has to make an intelligent choice between Integer and Real.