Saturday, May 23, 2020
What Is a Double in C, C++ and C# Programming
The double is a fundamental data type built into the compiler and used to define numeric variables holding numbers with decimal points. C, C,à C# and many other programming languages recognize the double as a type. A double type can represent fractional as well as whole values. It can contain up to 15 digits inà total, including those before and after the decimal point.à Uses for Double The float type, which has a smaller range, was used at one time because it was faster than the double when dealing with thousands or millions of floating-point numbers. Because calculation speed has increased dramatically with new processors, however, the advantages of floats over doubles are negligible. Many programmers consider the double type to be the default when working with numbers that require decimal points.à Double vs. Float and Int Other data types includeà floatà andà int. The double and float types are similar, but they differ in precision and range: A float is a single precision, 32-bit floating-point data type that accommodates seven digits. Its range is approximatelyà 1.5 Ãâ" 10âËâ45à to 3.4 Ãâ" 1038.A double is a double-precision, 64-bit floating-point data type. It accommodates 15 to 16 digits, with a range ofà approximatelyà 5.0à Ãâ"à 10âËâ345à to 1.7à Ãâ"à 10308. The int also deals with data, but it serves a different purpose. Numbers without fractional parts or any need for a decimal point can be usedà asà int. Thus, the int type holds only whole numbers, but it takes up less space, the arithmetic is usually faster, and it uses caches and data transfer bandwidth more efficiently than the other types.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.