// ATENCIO: s'ha de compilar amb el -lm
// gcc -o t9_math t9_math.c -lm

#include <stdio.h>
#include <math.h>

// #define PI 3.14159265358979323846264338327950288419716939937510

main() {
	printf("pow(3,5)=%lf\n",pow(3,5));
	printf("sqrt(5)=%lf\n",sqrt(5));
	printf("fabs(-4)=%lf\n",fabs(-4));

	printf("sin(PI/2)=%lf\n",sin(M_PI/2));
	printf("cos(PI/2)=%lf\n",cos(M_PI/2));
	printf("tan(PI/2)=%lf\n",tan(M_PI/2));	// retorna un número molt gran
		// però no infinit. Probablement per "error de redondeo"
		// o perquè PI no té prous decimals.
	printf("sqrt(-1)=%lf\n",sqrt(-1));	// -nan (Not a Number)
	printf("1.0/0=%lf\n",1.0/0);	// inf (Infinit)
		// Dona warning de "Divide by zero" al compilar
	printf("-1.0/0=%lf\n",-1.0/0);	// -inf (Infinit)
		// Dona warning de "Divide by zero" al compilar

	printf("isnan(sqrt(-1))=%d\n",isnan(sqrt(-1)));	// C99
	printf("isinf(1.0/0)=%d\n",isinf(1.0/0));	// C99
	printf("isinf(-1.0/0)=%d\n",isinf(-1.0/0));	// C99
}

