int signed and unsigned type memory--C

Source: Internet
Author: User


/*int signed 0xFFFFFFFF = = -10xfffffffe = 2 min 0x80000000 = = 21 4748 3648 maximum 0x7fffffff = = 4748 36470x00000001 = 10x0000000 0 = = 0int unsigned max 0xFFFFFFFF = 9496 7295 0x80000000 = 4748 36480x7fffffff = 21 4748 3647 min 0x00000000 = = 0*/

Intmain () {/* first participates in 5 int, 32-bit platform is 4 bytes, and the stack allocates 4 bytes of memory to hold the number of references 5.

The%f symbol will feel that this parameter is a double type. The printf function converts the float itself to a double, so the stack reads 8 bytes. So memory access is out of bounds. */printf ("5 =%f\n", 5);/* The 5.01 is a double type, and the storage is 8 bytes.

%d reads only 4 bytes. */printf ("5.01 =%d\n", 5.01);}

/*
[Email protected] test_class]#./a.out
5 = 0.000000
5.01 = 1889785610
[Email protected] test_class]#./a.out
5 = 0.000000
5.01 = 1889785610
[Email protected] test_class]#./a.out
5 = 0.000000
5.01 = 1889785610
*/

Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

int signed and unsigned type memory--C

Related Article

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.