Wrong value on calculating difference in hours between TimeCurrent() and TimeLocal()

Back to topics list  | 1 2 To post a new topic, please log in or register
avatar
12988
WHRoeder 2015.10.07 14:09 #
 
wemersonrv: WHRoeder, i don't get the point with the 1800 added to the equation.
  1. How do you round a double to an int?
    int res = int(dbl + 0.5); // 0.49 + 0.50 = 0.99 -> 0
                              // 0.51 + 0.50 = 1.01 -> 1
  2. How do you round seconds to an int hours?
    int    seconds = BrokerTime - ComputerTime;
    double hours   = double(seconds) / 3600.0;
    int TimeOffset = int(hours + 0.5);
  3. How do you round a int seconds to an int hours using only integer operations?
    int seconds    = BrokerTime - ComputerTime;
    int TimeOffset = (seconds + 1800)/3600; // 0.5 * 3600 = 1800

avatar
127
wemersonrv 2015.10.07 16:46 #
 
Ok, thanks!
Back to topics list   | 1 2  

To add comments, please log in or register