INT-type signed and unsigned memory -- C

Source: Internet
Author: User


/* Int signed 0 xffffffff =-10 xfffffffe =-2 min 0x80000000 =-21 4748 Max 0x7fffffff = 21 3648x4748 = 10x36470 = 0int unsigned maximum 0 xffffffff = 42 9496 7295 0x80000000 = 21 4748 36480x7fffffff = 21 4748 3647 Minimum 0x00000000 = 0 */

Intmain () {/* parameter 5 is int type, 32-bit platform is 4 bytes, and 4 bytes of memory is allocated in the stack for storing parameter 5. The % F symbol will regard this parameter as double type, and the printf function will automatically convert float to double type, so the stack reads 8 bytes. Therefore, memory access is out of bounds. */Printf ("5 = % F \ n", 5);/* The parameter 5.01 is double type and is stored in 8 bytes. % D reads only four of the four 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
*/

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.