Floating-point numbers in the C language

Source: Internet
Author: User

First, floating-point constants (decimals)

0.11L, 0.0f, 0.0,1.88,2.5f, 0.188E1

E3 103 such as 1.88E 3=1.88*1000=1880.0f

E-3 says 10-3, like 1.88e-3=1.88/1000=0.00188f.

Second, floating-point variable

Key words

Number of bytes

Range of values

Float

4

+3.4E38 (accurate to 6 decimal places)%f,%e to format

Double

8

+1.7E308 (accurate to 15 decimal places)%f,%e to format

Long double

12

+1.19E4932 (accurate to 18 decimal places)%lf,%le to format

Third, floating-point arithmetic

5/3 =

5.0/3=

Correct wording: printf ("10/3=%f\n", 10.0f/3.0f);

Iv. controlling the number of decimal digits

printf ("%0.3f \ n", 7/3);

printf ("10/3=%.2f\n", 10.0f/3.0f);

Floating-point numbers in the C language

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.