Demo entry 6760736

1

   

Submitted by anonymous on Sep 18, 2018 at 05:06
Language: C. Code size: 968 Bytes.

#include "stdio.h"
#include "limits.h" /* ANSI C标准规定:各种类型的取值范围必须在头文件<limits.h>中定义 */

/* 利用标准头文件来确定由signed及unsigned限定的char、short、int及long类型变量的取值范围 */
int main(int argc, char const *argv[])
{
	/*类型限定符signed与unsigned可以用于限定char类型或任何整型。unsigned类型的数总是正值或0,并遵循算术模2^n定律,其中0是该类型占用的位数。例如char对象占用8位,则unsigned char类型变量的取值范围为0~225,而在采用对二补码的机器上signed char类型变量的取值范围则为-127~128。 */
	printf("signed char min = %d\n",SCHAR_MIN );
	printf("signed char max = %d\n",SCHAR_MAX );
	printf("signed short min = %d\n",SCHAR_MIN );
	printf("signed short max = %d\n",SCHAR_MAX );
	printf("signed int min = %d\n",INT_MIN );
	printf("signed int max = %d\n",INT_MAX );
	printf("signed long min = %d\n",LONG_MIN );
	printf("signed long max = %d\n",LONG_MAX );
	/*unsigned types       */
	printf("unsigned char max = %u\n",UCHAR_MAX );
	printf("unsigned short max = %u\n",USHRT_MAX );
	printf("unsigned int max = %u\n",UINT_MAX );
	printf("unsigned long max = %1u\n",ULONG_MAX );
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).