Floating Point Numbers

Examples are: Single, Double and Date

These are numbers that can be expressed as mm E ee, where mm is the mantissa and ee is the exponent (power of 10).
You can use floating point to save the value of number.
This method is called floating point because the the decimal point floats.
This method represents a number in an approximate way to a certain number of significant digits.
This is then scaled using an exponent.
The Single and Double data types are very precise, that is, they make it possible for you to specify extremely small or large numbers. However, these data types are not very accurate because they use floating-point mathematics.

Here multiplication and division are easy. In you just multiply/divide the floating parts and then add/subtract powers (In Division you have an extra step which is making sure that the floating part does not start with a zero).
In order to add or subtract you need to make sure that both numbers have the same power, so you have to shift the smaller number. Then you will do the addition/subtraction in the normal way and write the result in the scientific notation.


The Single data type requires 4 bytes of memory and can store negative values between -3.402823 x 1038 and -1.401298 x 10-45 and positive values between 1.401298 x 10-45 and 3.402823 x 1038. The Double data type requires 8 bytes of memory and can store negative values between -1.79769313486232 x 10308 and -4.94065645841247 x 10-324 and positive values between 4.94065645841247 x 10-324 and 1.79769313486232 x 10308.


Floating-point mathematics has an inherent limitation in that it uses binary digits to represent decimals. Not all the numbers within the range available to the Single or Double data type can be represented exactly in binary form, so they are rounded. Also, some numbers cannot be represented exactly with any finite number of digits, pi, for example, or the decimal resulting from 1/3.

Rounding Errors

Because of these limitations to floating-point mathematics, you might encounter rounding errors when you perform operations on floating-point numbers.
Compared to the size of the value you are working with, the rounding error will be very small.
If you do not require absolute accuracy and can afford relatively small rounding errors, the floating-point data types are ideal for representing very small or very large values.
On the other hand, if your values must be accurate - for example, if you are working with money values - you should consider one of the scaled integer data types.

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext