CMP EMBEDDED.COM

Login | Register     Welcome Guest RFID World  esc india  TeardownTV
 

Listing 3: Simple math on same granularity variables Listing 3: Simple math on same granularity variables

void Test1_7(FIXED1_7 a, FIXED1_7 b)
{
FIXED1_7 temp;
printf("Results of operations on 1_7 variables\n");
temp.full = a.full + b.full;
printf("Addition result is %d.%2.2d\n", temp.part.integer,
(temp.part.fraction*100+64)/128);
if (a.full < b.full)
{
printf("a is less than b. Subtraction overflows.\n");
}
if (a.full == b.full)
{
printf("a is the same as b. Result = 0.\n");
}
if (a.full > b.full)
{
temp.full = a.full - b.full;
printf("Subtraction result is %d.%2.2d\n", temp.part.integer, 
(temp.part.fraction*100+64)/128);
}
}
Embedded.com Career Center
Ready to take that job and shove it?
SEARCH JOBS

Browse all jobs

SPONSOR
RECENT JOB POSTINGS


 :