Bonjonr,

J'essaye de faire un traitement sur les erreurs mathématique de math.h dans un programme en C++ qui commence comme suit :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 */
  ...
  ..
  .
}
Je ne comprend pas pourquoi je ne passe jamais par ma fonction _matherr !
Merci d'avance vos suggestions