/*************************************************************************************************************************************/ /* */ /* G E S T I O N D E S D E C I M A L E S D ' U N N O M B R E T R A N S C E N D A N T : */ /* */ /* */ /* Nota : */ /* */ /* Cette commande est fonctionnellement */ /* identique a 'v $xtc/GestionDecimales.01$c' */ /* qui peut donc etre utilise en cas de probleme */ /* avec l'algorithme, la version '$c' etant */ /* evidemment plus rapide a compiler que la */ /* version '$K'... */ /* */ /* */ /* Author of '$xrv/GestionDecimales.01$K' : */ /* */ /* Jean-Francois COLONNA (LACTAMME, 20200830125805). */ /* */ /*************************************************************************************************************************************/ /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* I N T E R F A C E ' listG ' : */ /* */ /* */ /* :Debut_listG: */ /* :Fin_listG: */ /* */ /*************************************************************************************************************************************/ /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* D I R E C T I V E S S P E C I F I Q U E S D E C O M P I L A T I O N : */ /* */ /*************************************************************************************************************************************/ /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* F I C H I E R S D ' I N C L U D E S : */ /* */ /*************************************************************************************************************************************/ #include INCLUDES_BASE /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* V A L E U R S I M P L I C I T E S D E S P A R A M E T R E S : */ /* */ /*************************************************************************************************************************************/ #define PLUS_PETITE_DECIMALE \ ZERO #define PLUS_GRANDE_DECIMALE \ SOUS(BASE10,BEGIN_AT_0) /* Definition du segment des decimales... */ #define PREMIER_NUMERO_ETENDU \ FZERO #define PAS_NUMERO_ETENDU \ FU /* Premier numero a utiliser et pas de progression. Le "_ETENDU" signifie que le type du */ /* numero est pass de 'Int' a 'Flot' le 20200831150345... */ /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* D E F I N I T I O N D U F I C H I E R : */ /* */ /*************************************************************************************************************************************/ #include xrv/ARITHMET.1d.I" #include xrv/ARITHMET.21.I" #include xrv/champs_5.41.I" #define VALEUR_IMPLICITE \ FZERO gGENERATION_D_UN_FICHIER(fichier_des_valeurs,liste_des_valeurs); /* Definition en memoire du fichier. */ #define ELEMENT_DU_FICHIER(index) \ gELEMENT_DU_FICHIER(liste_des_valeurs,index) \ /* Acces a un element courant du fichier. */ /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* M A C R O S U T I L E S : */ /* */ /*************************************************************************************************************************************/ #define INCREMENTATIONS_DIVERSES \ Bblock \ EGAL(numero_courant_etendu_a_editer,numero_courant_etendu); \ \ INCR(decimale_courante,I); \ \ Test(IFGT(decimale_courante,plus_grande_decimale)) \ Bblock \ EGAL(decimale_courante,plus_petite_decimale); \ Eblock \ ATes \ Bblock \ Eblock \ ETes \ \ INCR(numero_courant_etendu,pas_numero_etendu); \ Eblock /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* G E S T I O N D E S D E C I M A L E S D ' U N N O M B R E T R A N S C E N D A N T : */ /* */ /*************************************************************************************************************************************/ BCommande(nombre_d_arguments,arguments) /*-----------------------------------------------------------------------------------------------------------------------------------*/ Bblock #include xrv/ARITHMET.22.I" #include xci/valeurs.03.I" DEFV(Int,INIT(plus_petite_decimale,PLUS_PETITE_DECIMALE)); DEFV(Int,INIT(plus_grande_decimale,PLUS_GRANDE_DECIMALE)); /* Definition du segment des decimales... */ DEFV(Float,INIT(premier_numero_etendu,PREMIER_NUMERO_ETENDU)); DEFV(Float,INIT(pas_numero_etendu,PAS_NUMERO_ETENDU)); /* Premier numero a utiliser et pas de progression. Le "_ETENDU" signifie que le type du */ /* numero est passe de 'Int' a 'Flot' le 20200831150345... */ /*..............................................................................................................................*/ #include xrv/champs_5.1A.I" GET_ARGUMENTS_(nombre_d_arguments ,BLOC(PROCESS_ARGUMENT_I("nombre_elements=""ne=",nombre_d_elements ,BLOC(VIDE;) ,BLOC(Bblock PRINT_AVERTISSEMENT("'ne=' doit etre defini avant toute entree de fichiers"); Eblock ) ); PROCESS_ARGUMENTS_DE_DEFINITION_DES_FICHIERS_01; PROKESF_ARGUMENT_FICHIER("fichier=" ,fichier_des_valeurs ,liste_des_valeurs ,VALEUR_IMPLICITE ,lTRANSFORMAT_0d ,iGENERATION_D_UN_FICHIER ); PROCESS_ARGUMENTS_DE_PARAMETRAGE_DE_LA_GENERATION_DE_SUITE_DE_VALEURS_3; PROCESS_ARGUMENTS_DE_PARAMETRAGE_DE_LA_GENERATION_DE_SUITE_DE_VALEURS_1; GET_ARGUMENT_I("plus_petite_decimale=""ppd=",plus_petite_decimale); GET_ARGUMENT_I("plus_grande_decimale=""pgd=",plus_grande_decimale); GET_ARGUMENT_F("premier_numero=""premier=",premier_numero_etendu); GET_ARGUMENT_F("pas_numero=""pas=",pas_numero_etendu); ) ); Test(IFGT(plus_petite_decimale,plus_grande_decimale)) Bblock PRINT_ERREUR("le segment est mal defini, l'ordre est retabli"); SWAP(plus_petite_decimale,plus_grande_decimale); Eblock ATes Bblock Eblock ETes begin_nouveau_block Bblock DEFV(Int,INIT(decimale_courante,UNDEF)); /* Decimale courante... */ DEFV(Float,INIT(numero_courant_etendu,premier_numero_etendu)); /* Numero courant... */ EGAL(decimale_courante,INTE(numero_courant_etendu)); gOPERATION_SUR_LES_FICHIERS(BLOC( DEFV(Float,INIT(valeur_courante,ELEMENT_DU_FICHIER(index))); /* Recuperation de la valeur courante dans le fichier. */ DEFV(Int,INIT(nombre_courant,UNDEF)); DEFV(Float,INIT(numero_courant_etendu_a_editer,FLOT__UNDEF)); /* Donnees utiles... */ EGAL(nombre_courant,INTE(valeur_courante)); Test(N_EST_PAS_ENTIER(valeur_courante)) Bblock PRINT_ERREUR("une valeur n'est pas entiere"); CAL1(Prer1("(il s'agit de %f)\n",valeur_courante)); Eblock ATes Bblock Eblock ETes Test(IFEXff(nombre_courant,plus_petite_decimale,plus_grande_decimale)) Bblock PRINT_ERREUR("une valeur n'est pas dans le segment, la borne inferieure est forcee"); CAL1(Prer3("(il s'agit de %d qui n'est pas dans [%d,%d])\n" ,nombre_courant ,plus_petite_decimale ,plus_grande_decimale ) ); EGAL(nombre_courant,plus_petite_decimale); Eblock ATes Bblock Eblock ETes Test(IFEQ(nombre_courant,decimale_courante)) Bblock INCREMENTATIONS_DIVERSES; Eblock ATes Bblock Tant(IFNE(nombre_courant,decimale_courante)) Bblock INCREMENTATIONS_DIVERSES; Eblock ETan INCREMENTATIONS_DIVERSES; Eblock ETes ) ,numero_courant_etendu_a_editer ,EDITER_LA_VALEUR_RESULTANTE_DANS_gOPERATION_SUR_LES_FICHIERS ,nombre_d_exemplaires_du_resultat_de_l_operation_sur_les_valeurs_courantes ); Eblock end_nouveau_block lGENERATION_D_UN_FICHIER(liste_des_valeurs,VALEUR_IMPLICITE); RETU_Commande; Eblock ECommande