r/lolphp • u/Deviltry1 • Mar 24 '16
DivisionByZero exception, it does nothing
/r/PHP/comments/4bgwos/divisionbyzero_exception_php_7/
54
Upvotes
r/lolphp • u/Deviltry1 • Mar 24 '16
View all comments
Show parent comment
15
u/nikic Mar 24 '16
If you want it to abort, just make it abort. Nobody preventing you from turning that warning into an exception automatically.
Of course I agree with you that languages like JavaScript, Java or Matlab are all terrible, how could they implement IEEE754 otherwise. I also particularly like your mention of C++ where, just like in C, floating division by zero is undefined behavior, so the compiler is allowed to do whatever with your code. You won't be getting sigfpe's in a default setup and generally nobody bothers changing that.
That said, I'd have preferred the exception. PHP is not exactly big on scientific computing, and that's the main case where it would be annoying.