Value range of various basic data types defined by the compiler in C/C ++

Source: Internet
Author: User

It seems that some compilers do not fully support all data types, and the running results may vary depending on the compiler, but the obtaining methods are the same.

# Include <stdio. h>
# Include <limits. h>
# Include < Float . H>
# Include <stdlib. h>
Int Main ( Void )
{
Printf ( " Char type variable storage value from % d to % d \ n " , Char_min, char_max );
Printf ( " The storage value of unsigned char type variables ranges from 0 to % u \ n. " , Uchar_max );
Printf ( " Short Type Variable storage value from % d to % d \ n " , Shrt_min, shrt_max );
Printf ( " The storage value of unsigned short type variables ranges from 0 to % u \ n. " , Ushrt_max );
Printf ( " Int type variable storage value from % d to % d \ n " , Int_min, int_max );
Printf ( " The storage value of unsigned int type variables ranges from 0 to % u \ n. " , Uint_max );
Printf ( " Long type variable storage value from % LD to % LD \ n " , Long_min, long_max );
Printf ( " The storage value of unsigned long variables ranges from 0 to % lu \ n. " , Ulong_max );
Printf ( " Long long type variable storage value from % LLD to % LLD \ n " , Llong_min, llong_max );
Printf ( " Unsigned long type variable storage value from 0 to % LlU \ n " , Ullong_max );
Printf ( " The minimum non-zero float variable value is %. 3e \ n. " , Flt_min );
Printf ( " The maximum float type variable value is %. 3e \ n. " , Flt_max );
Printf ( " The minimum non-zero double type variable value is %. 3e \ n. " , Dbl_min );
Printf ( " The maximum value of the double type variable is %. 3e \ n. " , Dbl_max );
Printf ( " The minimum non-zero long double type variable value is %. 3le \ n. " , Ldbl_min );
Printf ( " The maximum value of the Long double type variable is %. 3le \ n. " , Ldbl_max );
Printf ( " Float Type variables provide % u decimal places \ n " , Flt_dig );
Printf ( " Double type variables provide % u decimal places \ n " , Dbl_dig );
Printf ( " Long double type variables provide % u decimal places \ n " , Ldbl_dig );
System ( " Pause " );
Return 0 ;

}

The running result is as follows:

Char type variable storage value from-128 to 127

Unsigned char type variable storage value from 0 to 255

Short Type Variable storage value from-32768 to 32767
Unsigned short type variable storage value from 0 to 65535
Int type variable storage value from-2147483648 to 2147483647
Unsigned int type variable storage value from 0 to 4294967295
Long type variable storage value from-2147483648 to 2147483647
The storage value of unsigned long type variables ranges from 0 to 4294967295

LongLong type variable storage value from-9223372036854775808 to 9223372036854775807
UnsignedLongLong type variable storage value from 0 to 18446744073709551615
The minimum non-zero float type variable value is 1.175e-038
The maximum float type variable value is 3.403e +038
The value of the smallest non-zero double type variable is 2.225e-308
The maximum value of the double type variable is 1.798e +.308

The value of the smallest non-zero long double type variable is-0.000e + 000
The value of the maximum long double type variable is-1. # Qoe +000
Float Type variables provide six decimal places of Precision
Double type variables provide 15 decimal places of Precision

LongDouble type variables provide 18-bit decimal places

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.