1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
int _matherr (struct _exception *a)
{
char err[200],er[100]="";
if (a->type==DOMAIN) strcpy(er,"DOMAIN");
if (a->type==SING) strcpy(er,"SING");
if (a->type==OVERFLOW) strcpy(er,"OVERFLOW");
if (a->type==UNDERFLOW) strcpy(er,"UNDERFLOW");
if (a->type==TLOSS) strcpy(er,"TLOS");
printf(err,"'%s' %s Error",a->name,er);
}
int main(int argc, char *argv[])
{
double x = -2.0, y;
y = sqrt(x); /* DOMAIN */
printf("Racine carree de %lf = %lf\n", x, y);
y = exp(1000); /* OVERFLOW */
y = exp(-1000); /* UNDERFLOW */
y = sin(1e100); /* TLOSS */
...
..
.
} |
Partager