Hi Guys, I'm working with the Metrowerks CodeWarrior MOT V1.2 Compiler for the HCS12. I've noticed that working with integers, long or float values, when you divide any number by zero, you get zero as a result. (I've also checked that the variable 'errno' is always zero) I would expect some sort of division by zero trap implemented in the runtime libraries, or at least that the result is the largest positive / negative number, but not zero. Is this behavior common ? How is division by zero treated in the other compilers (Cosmic, ICC12) ? Thank you all in advance, Regards. Guillermo. 

Metrowerks  Division by zero
Started by ●September 2, 2002
Posted by ●September 5, 2002
if you do a int/char division, usually compilers will directly generate
division code for it, so there will be no 'errno' flagging. what you will get then as result is what you get from the CPU for the IDIV/IDIVS instructions. There is no special 'division by zero' exception handling in the cpu core itself. I think you expect maybe something which is present on a CPU32, but not on a HC12. Erich > Original Message > From: Guillermo F. Molina [mailto:] > Sent: Monday, September 02, 2002 6:24 AM > To: > Subject: [68HC12] Metrowerks  Division by zero > Hi Guys, > > I'm working with the Metrowerks CodeWarrior MOT V1.2 Compiler for the HCS12. > I've noticed that working with integers, long or float values, when you divide any number by zero, you get zero as a > result. (I've also checked that the variable 'errno' is always zero) > I would expect some sort of division by zero trap implemented in the runtime libraries, or at least that the result is > the largest positive / negative number, but not zero. > Is this behavior common ? > How is division by zero treated in the other compilers (Cosmic, ICC12) ? > > Thank you all in advance, > > Regards. > Guillermo. > >  > > ">http://docs.yahoo.com/info/terms/ 