This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

OVERFLOW

HI Can anyone tell me that


 unsigned char time;
 .....
 void interrupt_timer ( void ) interrupt 1
{
   time++;
}

The unsigned char is of 1 byte and has maximum value of 255. So what will happen when the time exceeds 255?

Parents
  • It is considered politically incorrect to design current hardware with something else than two-complement integers of size 2^n so it is extremely likely that it will happen with most hardware produced the last 20 years.

    But special hardware can have a reason to behave similar to IEEE floating point, i.e. to "lock" into +Infinity or -Infinity, to let the software notice that the value is invalid instead of producing bogus computation results. Not as strong protection as IEEE fp where +/- Inf and NaN have special meaning for +, -, *, /, sqrt, ... too, but at least a possibility for the software to see that a specific input operand can't be trusted.

Reply
  • It is considered politically incorrect to design current hardware with something else than two-complement integers of size 2^n so it is extremely likely that it will happen with most hardware produced the last 20 years.

    But special hardware can have a reason to behave similar to IEEE floating point, i.e. to "lock" into +Infinity or -Infinity, to let the software notice that the value is invalid instead of producing bogus computation results. Not as strong protection as IEEE fp where +/- Inf and NaN have special meaning for +, -, *, /, sqrt, ... too, but at least a possibility for the software to see that a specific input operand can't be trusted.

Children