04-18-2010 07:39 PM
I am looking for the most computationaly efficient method to subtract two unsigned integers, such that they do not wrap around. That is 8 - 5 = 3, and 5 - 8 = 0.
I am doing this calculation about 50,000,000,000 times in my application, so computational efficiency is quite important(even saving 1 CPU cycle would be very significant). My current implementation is:
unsigned int A = 5, B = 8;
unsigned int Result;
loop many times
if ( B < A)
Result = Result + A - B;
04-19-2010 12:28 AM
Hi,
if code optimization is important, you probably should not stick to CVI but rather choose an optimizing compiler such as from Intel for Microsoft.
The CVI compiler is oriented towards debugging and does not include optimization capabilities.