Home |
RTKernel-32 Programming Manual Fine Time Arithmetic Functions |
Fine Time Arithmetic FunctionsModule FineTime contains some functions to simplify arithmetic with 64-bit high resolution times: DWORD FTIntMultDiv(DWORD Factor1, DWORD Factor2, DWORD Divisor); DWORD FTDivide (const RTKFineTime * T, DWORD Divisor); RTKFTIMEINT FTAdd (RTKFineTime * Result, const RTKFineTime * T1, const RTKFineTime * T2); RTKFTIMEINT FTSubtract (RTKFineTime * Result, const RTKFineTime * T1, const RTKFineTime * T2); RTKFTIMEINT FTMultiply (RTKFineTime * Result, const RTKFineTime * T, DWORD Factor); RTKFTIMEINT FTShift (RTKFineTime * Result, int Digits); RTKFTIMEINT FTMultDivDouble(RTKFineTime * Result, const RTKFineTime * Factor1, DWORD Factor2, DWORD Divisor); RTKFTIMEINT can be a 32-bit or 64-bit integer type. Please see section Module FineTime in the RTKernel-32 Programming Manual for details. FTIntMultDiv returns Factor1 * Factor2 / Divisor. The intermediate result of the multiplication is maintained as a 64-bit value. FTDivide calculates and returns (*T) / Divisor (rounded down). FTAdd calculates and returns (*Result) = (*T1) + (*T2). FTSubtract calculates and returns (*Result) = (*T1) - (*T2). FTMultiply calculates and returns (*Result) = (*T) * Factor. FTShift calculates and returns (*Result) << Digits. For negative Digits, (*Result) is shifted right. FTMultDivDouble calculates and returns (*Result) = Factor1 * Factor2 / Divisor. The intermediate result of the multiplication may exceed 64 bits. Functions FTIntMultDiv and FTDivide can trigger an exception if the divisor is zero or the result would exceed 32 bits. None of the functions detect overflows; the most significant bits which do not fit into the result are discarded. This behavior corresponds to the C/C++ operators for unsigned integers such as +, -, *, /, etc.
|