Re:Taking PHP Seriously
by oliverkyss on Friday October 14, 2016 @07:19AM
(#12707342)
Why would that be surprising? NaN as a result definitely means that you cannot multiply array by object in JS either.
JavaScript uses IEEE 754 special values, not exceptions on arithmetic errors (eg 1/0 returns Infinity instead of throwing). If you bother to learn the language, it doesn't surprise you.
[ Parent
| on HN ]
Re:Taking PHP Seriously
by happyslobro on Friday October 14, 2016 @09:22AM
(#12707863)
The problems start when you notice that your untyped key-value store has a bunch of NaNs where you were expecting a number. At this point, all you can do is pray that those numbers weren't very important, in the grand scheme of things.
Re:Taking PHP Seriously
by oliverkyss on Friday October 14, 2016 @11:14AM
(#12708602)
So when you do calculations with important numbers, you just push the results to the store without checking them and hope for the best?
NaNs can happen in any language with floats, it's just that some languages also use exceptions in some situations.
Re:Taking PHP Seriously
by codedokode on Friday October 14, 2016 @01:44PM
(#12709796)
You can check the result of every operation manually but it saves you time when the language does it.