0
Why we use double datatype in c ? Give some example for double datatype
2 odpowiedzi
+ 1
Double is a floating point values and is used for decimals and exponentials. For example, a double can be 3.4 which is a floating point decimal value, and it can also be something like 3E which is an exponential. The difference between the double and float, which is another floating point type is that a double can store larger values, up to 8 bytes, while a float can store 4 bytes. This means that the double can store more accurate floating point values. An example of the usage of a double could be when calculating something. If we store 3/2 as an int, we would get it as a whole decimal, usually 1. If we store 3/2 as a double, we would get 1.5, a floating point value.
0
The different data types are used based on needed scope of value or precision for float types. The data types represent different bit lengths. Remember 8 bits to a byte. And the max value of a data type being 2^n where n is the index of the bit. There is arguably more precision and greater scope of value between the float type variables of float and double, double being twice the size. In bit length. For float types the bits are broken up into the sign bit, the base bits, and the exponent bits.