How does JVM or for that matter CLR (Common language runtime) handles divided by zero?
Does it check denominator every time, before executing divide instruction?
Or is it handled using call back function which get invoked when “divide by zero” trap raised by processor?
Any input will be appreciated.
Thank you,
Alan
All processors I know generate a hardware trap for this. Which is handled by the operating system and reflected into the user mode code with an OS dependent mechanism (signal, exception, etc). Which the runtime picks up and translates into a Java or .NET exception.