Why !! (Double or not ?)

Source: Internet
Author: User

When reading the cache of each CPU page, you can see the following:Code:

Static inlinestruct page * buffered_rmqueue (struct zone * preferred_zone, struct zone * zone, int order, gfp_t gfp_flags, int migratetype) {int cold = !! (Gfp_flags & _ gfp_cold );

Why !! What about it?

-----------------------------------------------------------------------------

It is said that the C/C ++ compiler thinks that: 0 is false, 1 is true, and that non-0 (except 1) is also true, and non-0 is 0, non-non-0 is 1. Why !! (X) processing, I think it should be caused by data truncation during type conversion. For example, the parameter in if () is int, but X is long. If X is 0x11111111 00000000, it is true, but if (x, it may be truncated to 0 if (!! (X.

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.