Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have two time value in long long format as follows:
long long t1 = 1130;
long long t2 = 2652;

I need to compare these two values that which one is greater.

What I have tried:

I have tried to find out that which time is bigger one.
Posted
Updated 27-May-21 3:35am
Comments
Patrice T 27-May-21 9:26am    
and you have some code ?
Member 15025528 27-May-21 9:33am    
No Patrice, I don't hae the code
Patrice T 27-May-21 9:38am    
and you know how to compare 2 integers ?
Richard MacCutchan 27-May-21 10:02am    
Use an if statement or a ternary expression.

And why are you using long long types for such small numbers?

1 solution

Of course t2 is greater than t1, unless your clock goes backward or unless your clock wrapped around going forward (that's another way to say you did not provide enough info).
 
Share this answer
 
Comments
Greg Utas 24-Sep-21 7:10am    
5. It's a long long, so probably in ticks, in which case 0 should be the time of the last system startup and it won't wrap around for a very, very long time.
CPallini 24-Sep-21 7:35am    
Thank you, even if..., it's a long long time!
:-)
Greg Utas 24-Sep-21 7:47am    
LOL. I didn't notice that. The question was at the top of the list today, so it must have been the victim of spam that had already been removed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900