INT calc_chkerror (LONG num)
// Check upper and lower bounds for the display.
// i.e. 99999999 and -99999999.
{ if ((num >= -999999论文范文http://www.chuibin.com/ 9) && (num <= 9999999))
return OK;本文来自辣.文,论-文·网原文请找腾讯324.9114
else
return ERROR;
}
VOID calc_output (INT status)
// Output according to the status of the operation.
// *Sleep* is used for the first op press after a full cancel
// or on startup.
{ switch (status)
{ case OK : calc_display(calc_decascii(lvalue)); break;
case SLEEP : break;
case ERROR : calc_display("Exception "); break;
default : calc_display("Exception "); break;
}
}
LONG calc_asciidec (CHAR *buffer)
// Convert the ASCII string into the floating point number.
{ LONG data value;
LONG data digit;
value = 0;
while (*buffer != ' ')
{ digit = *buffer - 48;
value = value*10 + digit;
buffer++;
}
return value;
}
CHAR *calc_decascii (LONG num)
// A rather messy function to convert a floating
// point number into an ASCII string.
{ LONG data temp = num;
CHAR xdata *arrayptr = &outputbuffer[MAX_DISPLAY_CHAR];
LONG data divisor = 10;本文来自辣.文,论-文·网原文请找腾讯32,49114
LONG data result;
CHAR data remainder,asciival;
INT data i;
// If the result of the calculation is zero
// insert a zero in the buffer and finish.
if (!temp)
{ *arrayptr = 48;
goto done;
}