Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22177

sqrt is only defined when argument is nonnegative

$
0
0

This compiles fine

#include <math.h>int main(void) {    double i = sqrt(9.0);}

If I change 9.0 to -9.0, then my compiler (GNU C) gives an error about an undefined reference to 'sqrt'.

I was expecting the sqrt function to return NaN or an exception. How does the C library only define sqrt for non-negative arguments?


Viewing all articles
Browse latest Browse all 22177

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>