Conversation
|
This is unfortuntaelly not unique, e.g., see
But as I read it out, according to IEEE 754 it should behave like the proposed patch. More importantly, if the change will be accepted I guess all the other math function should be checked, e.g., against setting the errno value. I didn't know that math functions could have such side effects (which also prevents optimization BTW). |
Yes, I wrote the test cases using glibc and whatever c lib MacOS is using (I assume that it's some BSD derivative) and they both return NaN. As far as errno is concerned we could look into what other libs do. I don't think musl for example sets errno but I need to double check that. I would be nice to not having to implement any side effects. Update: glibc sets EDOM just like clib2 does right now so I updated the patch to just change the return value to NAN when the input is < 0 and leave the rest as it is. |
Did some more digging and there are quite a few functions like sqrt, with return values / errno codes that can be discussed. |
When testing libstdc++ sqrt gave incorrect results. Negative arguments should give a NaN return value. Refer to this.