Two unsigned types want to subtract the result stored temporary variable or unsigned type

Source: Internet
Author: User

1#include <stdio.h>2 intMain ()3 {4UnsignedintDwval =0;5unsigned __int64 n64val =1;6     if(Dwval-n64val >= -)7     {8printf"%i64d\n", Dwval-n64val);//execute this line, output-19     }Ten     return 0; One}

Personal analysis:

When you do want to reduce the operation (Dwval-n64val), the Dwval and N64val are converted to unsigned __int64,
The two want to reduce the result is-1, storage for 0xFFFFFFFFFFFFFFFF, as unsigned __int64 use
Compared to the following number (20), the result of the calculation is true, and the result of the printout is the __int64 type
The corresponding value is-1

Further verification:

1#include <iostream>2 intMain ()3 {4UnsignedintDwval =0;5unsigned __int64 n64val =1;6unsigned __int64 N64val2 =0xffffffffffffffff;7     if(Dwval-n64val >=n64val2)8     {9printf"%i64d\n", Dwval-n64val);//execute this line, output-1Ten     } OneN64val2 = Dwval-n64val;//N64val2 = 0xffffffffffffffff ASystem"Pause"); -     return 0; -}
1#include <iostream>2 intMain ()3 {4UnsignedintDwval =0;5unsigned __int64 n64val =2;6unsigned __int64 N64val2 =0xffffffffffffffff;7     if(Dwval-n64val >=n64val2)8     {9printf"%i64d\n", Dwval-n64val);//Do not get hereTen     } OneN64val2 = Dwval-n64val;//N64val2 = 0xfffffffffffffffe, less than N64val2 ASystem"Pause"); -     return 0; -}

Thoughts on GetTickCount () 49.7 days after counting zero

_logtick = :: GetTickCount64 ();     // dosomething;    if (:: GetTickCount ()-_logtick >= Log_tick_max)    {        printf ("%i64d\n",:: GetTickCount ()- _logtick);    }

Two unsigned types want to subtract the result stored temporary variable or unsigned type

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.