Beispiel:
#include <stdio.h>
#include <math.h>
int main(void)
{
double a = 1., b = 0.;
double x;
x = a/b;
printf("%lf\n", x);
if ( x == HUGE_VAL )
printf("x konnte nicht exakt berechnet werden\n");
return 0;
}
Programmverhalten:
DOS MSC 6.0
0.000000
DOS BCC 4.52
Floating point error: Divide by 0.
Abnormal program termination
Win32 BCC 4.52
Programmabsturz
DOS GCC
Exiting due to signal SIGFPE
Floating Point exception at eip=00001571
Sol. GCC
Inf
x konnte nicht exakt berechnet werden
AIX GCC
INF
x konnte nicht exakt berechnet werden
AIX XLC
INF
x konnte nicht exakt berechnet werden
Eine Division durch Null wird von verschiedenen Systemen sehr
unterschiedlich behandelt:
#include <stdio.h>
#include <math.h>
int main(void)
{
double a = 1e200;
double x;
x = a*a;
printf("%lf\n", x);
if ( x == HUGE_VAL )
printf("x konnte nicht exakt berechnet werden\n");
return 0;
}
Programmverhalten:
DOS MSC 6.0
1.#INF00
DOS BCC 4.52
Floating point error: Overflow.
Abnormal program termination
Win32 BCC 4.52
Programmabsturz
DOS GCC
Inf
x konnte nicht exakt berechnet werden
AIX GCC
INF
x konnte nicht exakt berechnet werden
AIX XLC
INF
x konnte nicht exakt berechnet werden
Ein Gleitpunktüberlauf wird von verschiedenen Systemen sehr
unterschiedlich behandelt:
#include <stdio.h>
int main(void)
{
double a = 1e-200;
double x;
x = a*a;
printf("%lf\n", x);
return 0;
}
Programmverhalten:
DOS MSC 6.0
0.000000
DOS BCC 4.52
0.000000
Win32 BCC 4.52
0.000000
DOS GCC
0.000000
AIX XLC
0.000000
AIX GCC
0.000000
Ein Gleitpunktunterlauf führt im allgemeinen zu keiner besonderen
Reaktion: Das Ergebnis wird stillschweigend auf Null gesetzt.