none
Wrong comparing result of two long long variable RRS feed

  • Question

  • The code is:

    			if(deadline>now)
    			{
    	break;
    			}
    			percy_log("Current_time:%lld",now);
    			percy_log("Deadline:%lld",deadline);
    

    The result is:

    Current_time:27307726
    Deadline:100489237
    
    It should break, but not.

    Wednesday, October 29, 2014 10:53 AM

Answers

  • Hi Percy Xu,

    The break statement ends execution of the nearest enclosing loop or conditional statement in which it appears. Could you please provide us with the sample code snippet of the loop?

    If you run the code like:

    int deadline, now=100;
    	for (deadline = 98, 1; deadline++;)
            if (deadline>now)
    	{
    		break;
    	}
    	cout << "Current_time:%lld" << " " << now;
    	cout << endl;
    	cout << "Deadline:%lld" << " " << deadline << endl;	

    It will show the current_time and the deadline always because the "break" just ends up the "for" loop that doesn't include the last 3 lines.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Percy Xu Monday, March 6, 2017 3:49 AM
    Thursday, October 30, 2014 7:16 AM
    Moderator