-
For programmers, the difference between double and float is that double has a high accuracy, with 16 significant digits and 7 digits for float. However, double consumes twice as much memory as float, and the operation speed of double is much slower than float, and the name of the mathematical function in C language is different from float.
-
Basically, there is no difference, they all represent decimals.
However, their widths are not the same, or the precision is different, float is single, double is double.
They represent different ranges of decimals, and double can represent a larger range than float.
double is in memory and occupies 8 bytes, and float occupies 4 bytes.
The relationship between float and double is the same as the relationship between short and long.
-
The float is a single-precision entity that is stored in 4 bytes.
double is a double-precision entity that is stored in 8 bytes. When performing program operations, the float type data is always converted to double type data, which is automatic type conversion. So the result is the same.
However, the accuracy of float and double data is different, the number of significant digits of float type is 6 7 digits, and the number of double digits is 15 16 digits.
The above is in C.
-
Double is a keyword in the C language, which stands for double-precision floating-point type, which occupies 8 bytes of memory space, the value range is ", the significant digit of double precision is fully guaranteed is 15 digits, and 16 bits is only part of the value***.
In C, float and double are both floating-point numbers. The difference is that the range represented by double is larger than that of float, and the range of decimal parts is also higher than that of float.
For example, the number Pi, if expressed as a float, can only be accurate to 6 decimal places at most. Double, on the other hand, is accurate to about 15 decimal places.
The exact number depends on the compiler used, but there is not much difference between the compilers of each machine.
As for the integer part, the range of the integer part represented by the float is already large enough, and it can be represented to the trillion level, which is already boundless. The range of integers represented by double is even larger. In actual development, except for a few high-precision fields, basically, the use of float is sufficient.
-
Hello, glad to be able to answer 1The range of representation is different, and the decimal range and integer range represented by double are larger than float; In memory, it takes up 8 bytes, and float in memory, which takes up 4 bytes. 3.
The accuracy is not the same, float is single precision, double precision is double precision. float is a floating-point data type, and double is a double-precision floating-point data type, and double is more accurate than float.
-
Differences: 1. The accuracy is different, float is single precision, double is double precision;
2. The range of decimals is different, and the range that double can represent is larger than that of float;
3. Double is in memory, accounting for 8 bytes, and float is in memory, accounting for 4 bytes.
float: float data type, which is used to store single-precision floating-point numbers or double-precision floating-point numbers. Floating-point numbers use the IEEE (Institute of Electrical and Electronics Engineers) format.
A single-precision value of the floating-point type has 4 bytes and includes a sign bit, an 8-bit binary exponent, and a 23-bit mantissa number. Since the high sequential bit of the mantissa is always 1, it is not stored in numeric form. This representation provides a range of float types approximately between .
double: double-precision floating-point type, this data type is similar to single-precision data type (float), but the accuracy is higher than float, and the memory space occupied by compilation varies according to different compilers, which is a variable type of double float data type, which represents real variables in C C++.
-
1. The range of indicators is differentThe index range of the float is -127 128.
The index range for double and double is -1023 10242. The expression index is differentThe expression for float is 1 bit (sign bit) + 8 bits (exponential bit) + 23 bits (mantissa bit).
The expression of double is 1 bit (sign bit) + 11 bits (exponential bit) + 52 bits (mantissa bit).
3. The number of significant digits is differentFloats can only provide seven significant digits.
Double can provide 16 significant digits.
4. The memory space occupied is differentfloat occupies 4 bytes (32 bits) of memory space, and the value range is .
double occupies 8 bytes (64-bit) of memory space, and the value range is .
-
%f and %lf are the float type and double type, respectively, and are used to format the input and output symbols. So after changing to float, you have to change lf to f
-
int—Integer.
double—Double-precision floating-point.
float—Single-precision floating-point.
int is an integer variable that stores the integer value as a base type, int is a 32-bit integer in a 32-bit device and a 64-bit integer in a 64-bit device.
float and double refer to decimal variables, float is a 32-bit value and double is a 64-bit value, and when using decimals, the compiler always infers them as a double type, not a float type. Therefore, if you don't need 64-bit precision, you need to declare the variable as float in the display.
intbyte4 numeric range: -2147483648 +2147483647
floatbyte 4, value range, one decimal place).
double bytes, 8 numeric ranges, decimals).
Poria cocos, commonly known as Yun Ling, Pine Cocos, and Poria Cocos, is a fungus plant parasitic on the roots of pine trees, shaped like a sweet potato, with a black-brown skin and a white or pink inside. Poria cocos contains Poria polysaccharides, glucose, proteins, amino acids, organic acids, fats, lecithin, adenine, choline, ergosterol, a variety of enzymes and potassium salts. >>>More
River. It's so different from the lake! The river water is "raw water"! The lake is "stagnant water." >>>More
Evaporation is a vaporization process that occurs only on the surface of a liquid and can occur at any temperature. >>>More
1.The main ingredient of black coffee is caffeine, which can promote blood circulation, refresh the mind and fight fatigue. 2. >>>More