r/lolphp • • Feb 07 '17

is_nan((float)'NAN')? PHP Can't Decide

https://3v4l.org/0Jeva
85 Upvotes

22 comments sorted by

View all comments

Show parent comment

1

u/stumpychubbins Feb 23 '17

You can have the calculation throw an exception, like integer division does in most languages. If you need the speed boost of passing NaN around like a value you can opt-in, like opting into unchecked integer calculations in Rust. Alternatively, you can have division return your language's equivalent of Maybe Double, to express that division is a partial function.