Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Src/MicrosecondDelta.c
/* MicrosecondDelta.c */ |
/* |
* MicrosecondDelta.c |
* Copyright © 1994 Apple Computer Inc. All rights reserved. |
*/ |
#include "MicrosecondTrap.h" |
/* |
* Convert an epoch to microseconds (use floating-point operations). |
* Note that 4294967296.0 is 2^32, which is represented accurately |
* in double-precision floating point. Note that this can loose |
* low-order bits. |
*/ |
#define kTwoPower32 (4294967296.0) |
double |
MicrosecondToDouble( |
register const UnsignedWide *epochPtr |
) |
{ |
register double result; |
result = (((double) epochPtr->hi) * kTwoPower32) + epochPtr->lo; |
return (result); |
} |
/* |
* Return the difference between two Microsecond Trap values. |
* Integer subtraction is used to preserve accuracy. |
*/ |
void |
MicrosecondDelta( |
register const UnsignedWide *startPtr, |
register const UnsignedWide *endPtr, |
register UnsignedWide *result |
) |
{ |
if (endPtr->lo >= startPtr->lo) |
result->hi = endPtr->hi - startPtr->hi; |
else { |
result->hi = (endPtr->hi - 1) - startPtr->hi; |
} |
result->lo = endPtr->lo - startPtr->lo; |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14