apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Re: Why not POSIX time_t?
Date Mon, 15 Jul 2002 03:03:19 GMT
At 09:35 PM 7/14/2002, Aaron Bannert wrote:
>On Sun, Jul 14, 2002 at 07:27:04PM -0700, Brian Pane wrote:
>
>How exactly is the subtraction slower?I'm not at all sure what you
>mean by people matching on the struct directly...

For addition...

rtm.sec = tm1.sec + tm2.sec;
rtm.usec = tm1.usec + tm2.usec;
if (rtm.usec >= 1000000 && rtm.sec > 0) {
     rtm.usec -= 1000000
     ++rtm.sec;
}
else if (rtm.usec <= -1000000 && rtm.sec < 0) {
     rtm.usec += 1000000
     --rtm.sec;
}
else if (rtm.usec >= 0 && rtm.sec < 0) {
     rtm.usec -= 1000000
     ++rtm.sec;
}
else if (rtm.usec <= 0 && rtm.sec > 0) {
     rtm.usec += 1000000
     --rtm.sec;
}

For subtraction...

rtm.sec = tm1.sec + tm2.sec;
rtm.usec = tm1.usec + tm2.usec;
[ditto above conditionals]

Approximately, presuming that usec is always expressed in the
same sign as sec and signed values are allowed.  Remember that
addition may be n + -n, and contra wise for subtraction, so all the
same conditions apply

Bill


Mime
View raw message