/*************************************************************************************************************************************/ /* */ /* I N T E R P O L A T I O N E T E R R E U R S D ' A R R O N D I : */ /* */ /* */ /* Author of '$xtc/InterpolationErreursDArrondi.01$c' : */ /* */ /* Jean-Francois COLONNA (LACTAMME, 20220124104856). */ /* */ /*************************************************************************************************************************************/ #include <stdio.h> main() { double alpha=0.83,beta=0.17; double alpha_plus_beta; /* Ces valeurs viennent du probleme apparu dans 'v $xci/craque$K 20220123130027', puis */ /* decrit dans 'v $xiii/tri_image$FON 20220123133744'... */ int n; alpha_plus_beta = alpha+beta; printf("%.17f + %.17f = %.17f : est ",alpha,beta,alpha_plus_beta); if (alpha_plus_beta == 1) { printf("bien egal a 1\n\n"); } else { printf("different de 1\n\n"); } for (n=0 ; n<256 ; n++) { int interpolation=((alpha*n)+(beta*n)); if (interpolation != n) { printf("(%.17f*%d) + (%.17f*%d) = %d # %d\n",alpha,n,beta,n,interpolation,n); /* Ce qui donne : */ /* */ /* 0.82999999999999996 + 0.17000000000000001 = 1.00000000000000000 : est bien egal a 1 */ /* */ /* et malheureusement : */ /* */ /* (0.82999999999999996* 49) + (0.17000000000000001* 49) = 48 # 49 */ /* (0.82999999999999996* 53) + (0.17000000000000001* 53) = 52 # 53 */ /* (0.82999999999999996* 81) + (0.17000000000000001* 81) = 80 # 81 */ /* (0.82999999999999996* 89) + (0.17000000000000001* 89) = 88 # 89 */ /* (0.82999999999999996* 98) + (0.17000000000000001* 98) = 97 # 98 */ /* (0.82999999999999996*106) + (0.17000000000000001*106) = 105 # 106 */ /* (0.82999999999999996*115) + (0.17000000000000001*115) = 114 # 115 */ /* (0.82999999999999996*123) + (0.17000000000000001*123) = 122 # 123 */ /* (0.82999999999999996*162) + (0.17000000000000001*162) = 161 # 162 */ /* (0.82999999999999996*169) + (0.17000000000000001*169) = 168 # 169 */ /* (0.82999999999999996*178) + (0.17000000000000001*178) = 177 # 178 */ /* (0.82999999999999996*187) + (0.17000000000000001*187) = 186 # 187 */ /* (0.82999999999999996*196) + (0.17000000000000001*196) = 195 # 196 */ /* (0.82999999999999996*212) + (0.17000000000000001*212) = 211 # 212 */ /* (0.82999999999999996*221) + (0.17000000000000001*221) = 220 # 221 */ /* (0.82999999999999996*230) + (0.17000000000000001*230) = 229 # 230 */ /* (0.82999999999999996*246) + (0.17000000000000001*246) = 245 # 246 */ /* (0.82999999999999996*255) + (0.17000000000000001*255) = 254 # 255 */ /* */ } else { } } }