/*************************************************************************************************************************************/ /* */ /* T E S T D U P R O B L E M E 'v $xiii/aleat.2$vv$FON 20080924174528' : */ /* */ /* */ /* Author of '$xtc/noeud.11$c' : */ /* */ /* Jean-Francois COLONNA (LACTAMME, 20080925162951). */ /* */ /*************************************************************************************************************************************/ #include <stdio.h> typedef union di { double d; struct i { int i1; int i2; } i; } di; #define edit(x,message) \ { \ printf("%s=%.18f --> {%08x,%08x}",message,d(x),i(x),j(x)); \ printf("\n"); \ } #define d(x) (x.d) #define i(x) (x.i.i2) #define j(x) (x.i.i1) int IFLE(x,y) double x; double y; { return((x) <= (y)); } int IFGT(x,y) double x; double y; { return((x) > (y)); } #define INCR(x,i) x = ((x)+(i)) #define SOUS(x,y) ((x)-(y)) #define DECR(x,i) x = SOUS(x,i) main() { int chercher_le_noeud=1; di coordonnee_d_un_point; di maille; di coordonnee_du_centre; di coordonnee_du_noeud; i(coordonnee_d_un_point)=0x3fd99999;j(coordonnee_d_un_point)=0x9999999a; i(maille)=0x3fb99999;j(maille)=0x9999999a; i(coordonnee_du_centre)=0x00000000;j(coordonnee_du_centre)=0x00000000; i(coordonnee_du_noeud)=i(coordonnee_du_centre);j(coordonnee_du_noeud)=j(coordonnee_du_centre); edit(coordonnee_d_un_point,"point"); edit(maille,"maille"); edit(coordonnee_du_centre,"centre"); edit(coordonnee_du_noeud,"noeud"); while (chercher_le_noeud == 1) { if (IFGT(d(coordonnee_du_noeud),d(coordonnee_d_un_point))) { DECR(d(coordonnee_du_noeud),d(maille)); edit(coordonnee_du_noeud,"DECR(noeud)"); } else { if (IFLE(d(coordonnee_du_noeud),SOUS(d(coordonnee_d_un_point),d(maille)))) { INCR(d(coordonnee_du_noeud),d(maille)); edit(coordonnee_du_noeud,"INCR(noeud)"); } else { chercher_le_noeud=0; } } } edit(coordonnee_du_noeud,"noeud"); /* Le 20080925162951, on note les resultats suivants : */ /* */ /* point=0.400000000000000022 --> {3fd99999,9999999a} */ /* maille=0.100000000000000006 --> {3fb99999,9999999a} */ /* centre=0.000000000000000000 --> {00000000,00000000} */ /* noeud=0.000000000000000000 --> {00000000,00000000} */ /* INCR(noeud)=0.100000000000000006 --> {3fb99999,9999999a} */ /* INCR(noeud)=0.200000000000000011 --> {3fc99999,9999999a} */ /* INCR(noeud)=0.300000000000000044 --> {3fd33333,33333334} */ /* INCR(noeud)=0.400000000000000022 --> {3fd99999,9999999a} */ /* noeud=0.400000000000000022 --> {3fd99999,9999999a} */ /* */ /* sur toutes les MACHINEs apparemment... */ }