Demo entry 6760801

1

   

Submitted by anonymous on Sep 18, 2018 at 10:25
Language: C. Code size: 900 Bytes.

#include "stdio.h"

/*signed types */
int main(int argc, char const *argv[])
{
	printf("signed char min = %d\n",-(char)((unsigned char)~0>>1) );/*先把数字0的各个二进制位全部转换为1 */
	printf("signed char max = %d\n", (char)((unsigned char)~0>>1) );
	printf("signed short min = %d\n",-(short)((unsigned short)~0>>1) );
	printf("signed short max = %d\n", (short)((unsigned short)~0>>1) );
	printf("signed int min = %d\n", -(int)((unsigned int)~0>>1) );
	printf("signed int max = %d\n",  (int)((unsigned int)~0>>1 ));
	printf("signed long min = %1d\n",-(long)((unsigned long)~0>>1));
	printf("signed long max = %1d\n", (long)((unsigned long)~0>>1));

	/*unsigned types */

	printf("unsigned char max = %u\n",(unsigned char)~0);
	printf("unsigned short max =%u\n",(unsigned short)~0);
	printf("unsigned int min = %u\n",(unsigned int)~0 );
	printf("unsigned long max =%1u\n",(unsigned long)~0 );
	
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).