/*************************************************************************************************************************************/ /* */ /* T E S T D E S P R O B L E M E S D ' A R R O N D I S U R L E S O R D O N N E E S E N ' Pal ' : */ /* */ /* */ /* Author of '$xtc/Pal.11$c' : */ /* */ /* Jean-Francois COLONNA (LACTAMME, AAAAMMJJhhmmss). */ /* */ /*************************************************************************************************************************************/ #include <stdio.h> #define FLOAT 1 #define DOUBLE 2 #define PRECISION DOUBLE /* Precision des calculs... */ #if (PRECISION == FLOAT) # define CAST float # define EPSILON (1.0e-2) #else #endif #if (PRECISION == DOUBLE) # define CAST double # define EPSILON (1.0e-10) #else #endif #define F(x) ((CAST)(x)) #define I(x) ((int)(x)) #define FN(m,d,l) (F(m) + (F(d)*F(l))) #define N(m,d,l) I(FN(m,d,l) + EPSILON) #define DN(m,d,l) ((F(l)-F(m))/F(d)) #define FNY(y) FN(Ymin,dimY,y) #define NY(y) N(Ymin,dimY,y) #define DNY(y) DN(Ymin,dimY,y) #define dimY (Ymax-Ymin+0) /* Il est plus logique d'utiliser '+0' que '+1'... */ main() { CAST Ymin=0; CAST Ymax=574; /* Definition du format 'Pal' en vertical ; c'est uniquement lui qui pose probleme (est-ce */ /* parce que 575 est impair ?). */ CAST Yf; int Y; Y = Ymin; printf("\n EPSILON = %.17g",EPSILON); printf("\n minimum normalise = %g",DNY(Ymin)); printf("\n maximum normalise = %g",DNY(Ymax)); for (Yf=0 ; Yf <= DNY(Ymax) ; Yf=Yf+2*DNY(1)) { if (Y == NY(Yf)) { } else { printf("\n probleme : %g ---> %.17g = %d # %d",Yf,FNY(Yf),NY(Yf),Y); } Y = Y + 2; } }