7.24 data type operator Complement

Source: Internet
Author: User
Data Type:Long 32-bit 4-byte 64-bit 8-byte vs2013 4-byte long 8-byte float 4-byte double 8 byte
Difference between % x and % P:Int main (){
Int num = 256; printf ("% P \ n", & num); // 0107 fafc printf ("% # P \ n", & num); // 0x0133 fafc
Printf ("% x \ n", & num); // 107 fafc printf ("% # x \ n", & num); // 0x0000fafc
}
Complement:The original code of a positive number is the same as the original code of a negative number. The original code of a negative number is the same as the original code of another normal negative number. remove and Add 1
-5 original code 1000 0101 makeup Code 1111 1011
Original code 1000 0101
Truncation:
 
 
  1. #include <stdio.h>
  2. int main()
  3. {
  4. Int num = 5555; // hexadecimal 0x15b3Small-end storage B3 15 ----- memory
  5. unsigned char c = Num; // B3 Only leaves low bytes
  6. Printf ("% d \ n", c); // output 179
  7. }



The bug that occurs when the unsigned type and INT type are added:Unsigned int A = 6; A +-10> 0 // This sentence is correct, because-10 is an int converted to an unsigned int negative number, it will become a very large positive number. // The sum is definitely greater than 0.
 
 
  1. #include <stdio.h>
  2. int main()
  3. {
  4. unsigned int a = 6;
  5. If (a-10> 0) // The result is treated as an unsigned integer.
  6. {
  7. printf("aaaaaaaaa\n");
  8. }
  9. }
The output result is aaaaaaaaa.


3.14:3.14 The default value is double type. To change to float type, use 3.14f.

, (Comma) OPERATOR:The result is the last value of int max = 5, 6, 10; => max = 10;

% Remainder OPERATOR:A negative number can be used for remainder. The result is the same as that of the devisor, but the floating point cannot be used for remainder.

From Weizhi note (wiz)

7.24 data type operator Complement

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.