Double,long double and array of variables memory overhead

Source: Internet
Author: User

IEEE754 the representation of floating-point numbers. The expression range of float type data in C language is -3.4*10^38~+3.4*10^38. Double is -1.7*10^-308~1.7*10^308,long double for -1.2*10^-4932~1.2*10^4932.

Type

Number of bits (bits)

Valid numbers

Range of values

Float

32

6~7

-3.4*10^38~+3.4*10^38

Double

64

15~16

-1.7*10^-308~1.7*10^308

Long double

128

18~19

-1.2*10^-4932~1.2*10^4932

Long double input: scanf ("%lf", &x); printf ("%.10LF", X);

In addition, the analysis of the use of memory consumption of arrays.

The int float is a 32-bit, or 4b=32bit

When you open an array of 10^7, the memory consumed is: 10^7*4B=39063KB=38MB

Short int is 16 bits, 10^7 array requires 19MB memory

Bool,char is a 8-bit, 10^7 array requires approximately 10MB of memory

Long long,double is 64 bits,10^7 array requires approximately 72MB of memory

A long double is 128 bits, and the10^7 array requires about 144MB of memory

Double,long double and array of variables memory overhead

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.