Mail Archives: djgpp-workers/2002/11/08/07:01:39
If I comment out the #include <math.h> from the program below then the
program compiles and links without any errors or warnings. The results are:-
date = 52.680000
date = 51.680000
decimalPart = 1072705824.000000
wholePart = 1077938047.000000
down = 1077939071.000000
If I include the #inclue <math.h> from the program below then the program
compiles and links without any errors or warnings. The results are:-
date = 52.680000
date = 51.680000
decimalPart = 0.680000
wholePart = 51.000000
down = 52.000000
These results are correct....
Does anyone know why I would get wrong results, but no error messages if I
do not include math.h? I would have expected to get error messages
indicating a problem rather than a bad exe.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <conio.h>
#include <dos.h>
#include <dir.h>
#include <string.h>
#include <time.h>
#include <limits.h>
int main()
{
double date;
double decimalPart = 0.0;
double wholePart = 0.0;
double down;
date = 52.68;
printf("date = %f\n", date);
decimalPart = fmod( date, 1.0 );
date -= 1.0;
wholePart = (double) floor( date);
down = ceil(date);
printf("date = %f\n", date);
printf("decimalPart = %f\n", decimalPart);
printf("wholePart = %f\n", wholePart);
printf("down = %f\n", down);
}
- Raw text -