IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C Discussion :

calculette multibases [Casse tête en C].


Sujet :

C

  1. #1
    Membre expérimenté
    Avatar de Luke spywoker
    Homme Profil pro
    Etudiant informatique autodidacte
    Inscrit en
    Juin 2010
    Messages
    1 077
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Etudiant informatique autodidacte

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 077
    Points : 1 742
    Points
    1 742
    Par défaut calculette multibases [Casse tête en C].
    Salut les C,
    Comme le titre l'indique je bosse sur un projet de calculette avec entres autres fonctions de conversion et de calcul dans les 4 bases suivantes:

    -Décimale.
    -Binaire.
    -Octal.
    -Hexadécimale.

    Bon après avoir construit les fonctions de conversion et de calcul j'ai attaquer une GUI avec ncurses, après une série d 'assertions:

    -) 10000 random values pour les entiers dans toutes les bases: résultat de type long long ou le string binaire, octal, hexadécimale correspondant.
    -) 10000 random values pour les floats dans toutes les bases: résultats de type long double ou le string binaire, octal, hexadécimale correspondant.

    Passer plusieurs fois a la moulinette... c'est du tout cuit pour la GUI.

    Mais ânes ignârd que je suis j'ai oublier un petit détails:
    Les valeurs négatives !!!

    Je me serai bien passer de votre aide, excusez la forme, mais je bute sur le fait que:

    Brefs après avoir essayer en négatif,
    ça passe en résultat de type (double) négatif pour la base binaire mais pas pour les autres bases (décimale omise).
    Et comme les fonctions de conversions sont très analogue je ne comprend pas pourquoi le binaire ça passe et pas les autres... I Hit a -Wall.

    Après mon séjours a l'hôpital pour commotion cérébrale je poste un process SOS:

    Voici le code de mes assertions pour vous mettre l'eau a la bouche mais si vous voulez m'aider il faudra télécharger les sources (y pas tant de sources que ça et c'est tout commenter).

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
     
    /*
     * hobdcalc 
     * Copyright (C) 2014 Bruggemann Eddie.
     * 
     * This file is part of hobdcalc  .
     * hobdcalc is free software: you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * hobdcalc is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with hobdcalc. If not, see <http://www.gnu.org/licenses/>
     * 
     ************************************************************************************/
     
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <tgmath.h>
    #include <ctype.h>
    #include <limits.h>
    #include <inttypes.h>
    #include <stdbool.h>
    #include <ctype.h>
    #include <errno.h>
    #include <sys/time.h>
     
    #include "conversion/utils/conversion_utils.c"
     
    #include "conversion/int_hex/calc_int_hex.c"
    #include "conversion/int_bin/calc_int_bin.c"
    #include "conversion/int_oct/calc_int_oct.c" 
     
     
    #include "conversion/float_to_bin/float_bin.c"
    #include "conversion/float_to_oct/float_oct.c"
    #include "conversion/float_to_hex/float_hex.c"
     
    #include "operations/int_result/calc_hex_int_operations.c"
    #include "operations/int_result/calc_oct_int_operations.c"
    #include "operations/int_result/calc_bin_int_operations.c"
     
    #include "operations/float_result/calc_hex_float_operations.c"
    #include "operations/float_result/calc_oct_float_operations.c"
    #include "operations/float_result/calc_bin_float_operations.c"
     
     
    /* hobdcalc can compute in the 
     * -) binar
     * -) octal
     * -) hexadecimal
     * bases without problems with unsigned values.
     * 
     * but i hit a wall because:
     * the binar computing work with signed values for floating operations 
     * and not in octal and hexadecimal bases, and the signed integer computing.
     * because the computing functions are very similary that is why i don't understand what go wrong !!!  
     * I it the -Wall -Wall -Wall !!!
     * 
     * I hope you will have no problems with the code who is in my very simplistic beginner style. 
     *
     * You must link the type generic math file with:
     * $ gcc hobdcalc.c -lm
     * to compil the code.
     * 
     * Thank's to everybody who try to help me, 
     * if the "C HEADS break this ugly -Wall i it in"
     * thank's to send the result of their work to:
     * mrcyberfighter@gmail.com
     * or forking this code what is authorize by his author throught the GPLv3 License. 
     * 
     * For information:
     * This programm has an ncurses user interface not provided here in case as long this big bug
     * will not be resolved. 
     * 
     * Note: I don't care about strtold() or strtoll() and the %x %o %a placeholders, only raw computing, because i made
     *       bad experience with it during developpment and testing.    
     * ******************************************************************************************************************/
     
    void float_operations_test(void) ;
     
    void integer_operations_test(void) ;
     
    int main() {
      /** float_operations_test() ; */
      /** integer_operations_test() ; */
      return 0 ;
     
    }
     
    void float_operations_test(void) {
      long double op1,op2 ;
      struct timeval tv ;
      char *op1_str=malloc(128) ;
      char *op2_str=malloc(128) ;
      int c ;
     
      for (c=0 ; c < 10000 ; c++) {
     
        gettimeofday(&tv,NULL) ;
        srand(tv.tv_usec / 4) ;
     
        op1=(double) (rand() % (9223372036854775807/2)) / ((rand() % (9223372036854775807/2))+1) ;
        /* set: 
         * op1 = - (double) (rand() % (9223372036854775807/2)) / ((rand() % (9223372036854775807/2))+1) ; // (long double) not work !!!
         * for help bugfix tests.
         * Thank's for your collaboration and your help.
         ******************************************/
     
        srand(tv.tv_usec / 3) ;
        op2=(double) (rand() % (9223372036854775807/2)) / ((rand() % (9223372036854775807/2))+1) ;
        /* set: 
         * op2 = - (double) (rand() % (9223372036854775807/2)) / ((rand() % (9223372036854775807/2))+1) ; // (long double) not work !!!
         * for help bugfix tests.
         * Thank's for your collaboration and your help.
         ******************************************/
     
        memset(op1_str,'\0',128) ;
        memset(op2_str,'\0',128) ;
        floattobinfloat(op1,op1_str) ;
        floattobinfloat(op2,op2_str) ;
        if (c % 10 == 0) {
          printf("iteration: %d\n",c) ;
        }
        if (op1 + op2 != binfloataddbinfloat(op1_str,op2_str) ) {
          printf("assertion bin error by iteration %Lf:\nop1: %s == %Lf\nop2: %s == %Lf\nresult: %Lf\nerror: %Lf\n",op1,op1_str,op1,op2_str,op2,op1+op2,binfloataddbinfloat(op1_str,op2_str)) ;
          break ;
        }
        if (op1 - op2 != binfloatsubbinfloat(op1_str,op2_str) ) {
          printf("assertion bin error by iteration %Lf:\nop1: %s == %Lf\nop2: %s == %Lf\nresult: %Lf\nerror: %Lf\n",op1,op1_str,op1,op2_str,op2,op1+op2,binfloatsubbinfloat(op1_str,op2_str)) ;
          break ;
        }
        if (op1 * op2 != binfloatmultbinfloat(op1_str,op2_str) ) {
          printf("assertion bin error by iteration %Lf:\nop1: %s == %Lf\nop2: %s == %Lf\nresult: %Lf\nerror: %Lf\n",op1,op1_str,op1,op2_str,op2,op1+op2,binfloatmultbinfloat(op1_str,op2_str)) ;
          break ;
        }
        if ( (long double) op1 / (long double) op2 != binfloatdivbinfloat(op1_str,op2_str) ) {
          printf("assertion bin error by iteration %Lf:\nop1: %s == %Lf\nop2: %s == %Lf\nresult: %Lf\nerror: %Lf\n",op1,op1_str,op1,op2_str,op2,op1+op2,binfloatdivbinfloat(op1_str,op2_str)) ;
          break ;
        }
        else {
          printf("%Lf\n%Lf\n%Lf\n%Lf\n",binfloataddbinfloat(op1_str,op2_str),binfloatsubbinfloat(op1_str,op2_str),binfloatmultbinfloat(op1_str,op2_str),binfloatdivbinfloat(op1_str,op2_str)) ;
        }
     
        memset(op1_str,'\0',128) ;
        memset(op2_str,'\0',128) ;
        floattohexfloat(op1,op1_str) ;
        floattohexfloat(op2,op2_str) ;
        op1_str[128]='\0' ;
        op2_str[128]='\0' ;
        if (op1 + op2 != hexfloataddhexfloat(op1_str,op2_str) ) {
          printf("assertion hex error by iteration %Lf:\nop1: %s == %Lf\nop2: %s == %Lf\nresult: %Lf\nerror: %Lf\n",op1,op1_str,op1,op2_str,op2,op1+op2,hexfloataddhexfloat(op1_str,op2_str)) ;
          break ;
        }
        if (op1 - op2 != hexfloatsubhexfloat(op1_str,op2_str) ) {
          printf("assertion hex error by iteration %Lf:\nop1: %s == %Lf\nop2: %s == %Lf\nresult: %Lf\nerror: %Lf\n",op1,op1_str,op1,op2_str,op2,op1+op2,hexfloatsubhexfloat(op1_str,op2_str)) ;
          break ;
        }
        if (op1 * op2 != hexfloatmulthexfloat(op1_str,op2_str) ) {
          printf("assertion hex error by iteration %Lf:\nop1: %s == %Lf\nop2: %s == %Lf\nresult: %Lf\nerror: %Lf\n",op1,op1_str,op1,op2_str,op2,op1+op2,hexfloatmulthexfloat(op1_str,op2_str)) ;
          break ;
        }
        if ( (long double) op1 / (long double) op2 != hexfloatdivhexfloat(op1_str,op2_str) ) {
          printf("assertion hex error by iteration %Lf:\nop1: %s == %Lf\nop2: %s == %Lf\nresult: %Lf\nerror: %Lf\n",op1,op1_str,op1,op2_str,op2,op1+op2,hexfloatdivhexfloat(op1_str,op2_str)) ;
          break ;
        }
        else {
          printf("%Lf\n%Lf\n%Lf\n%Lf\n",hexfloataddhexfloat(op1_str,op2_str),hexfloatsubhexfloat(op1_str,op2_str),hexfloatmulthexfloat(op1_str,op2_str),hexfloatdivhexfloat(op1_str,op2_str)) ;
        }
     
        memset(op1_str,'\0',128) ;
        memset(op2_str,'\0',128) ;
        floattooctfloat(op1,op1_str) ;
        floattooctfloat(op2,op2_str) ;
        if (op1 + op2 != octfloataddoctfloat(op1_str,op2_str) ) {
          printf("add assertion octal error by iteration %Lf:\nop1: %s == %Lf\nop2: %s == %Lf\nresult: %Lf\nerror: %Lf\n",op1,op1_str,op1,op2_str,op2,op1+op2,octfloataddoctfloat(op1_str,op2_str)) ;
          break ;
        }
        if (op1 - op2 != octfloatsuboctfloat(op1_str,op2_str) ) {
          printf("sub assertion octal error by iteration %Lf:\nop1: %s == %Lf\nop2: %s == %Lf\nresult: %Lf\nerror: %Lf\n",op1,op1_str,op1,op2_str,op2,op1+op2,octfloatsuboctfloat(op1_str,op2_str)) ;
          break ;
        }
        if (op1 * op2 != octfloatmultoctfloat(op1_str,op2_str) ) {
          printf("mult assertion oct error by iteration %Lf:\nop1: %s == %Lf\nop2: %s == %Lf\nresult: %Lf\nerror: %Lf\n",op1,op1_str,op1,op2_str,op2,op1+op2,octfloatmultoctfloat(op1_str,op2_str)) ;
          break ;
        }
        if ( (long double) op1 / (long double) op2 != octfloatdivoctfloat(op1_str,op2_str) ) {
          printf("div assertion oct error by iteration %Lf:\nop1: %s == %Lf\nop2: %s == %Lf\nresult: %Lf\nerror: %Lf\n",op1,op1_str,op1,op2_str,op2,op1+op2,octfloatdivoctfloat(op1_str,op2_str)) ;
          break ;
        }
        else {
          printf("%Lf\n%Lf\n%Lf\n%Lf\n",octfloataddoctfloat(op1_str,op2_str),octfloatsuboctfloat(op1_str,op2_str),octfloatmultoctfloat(op1_str,op2_str),octfloatdivoctfloat(op1_str,op2_str)) ;
        }
     
     
      }
      free(op1_str) ;
      free(op2_str) ;
     
      return  ;
    }
     
    void integer_operations_test(void) {
      int c ;
      long long op1,op2 ;
      char *op1_str, *op2_str ;
      op1_str=malloc(128) ;
     
      op2_str=malloc(128) ;
     
      struct timeval tv ;
     
      for (c=0 ; c < 10000 ; c++) {
        srand(tv.tv_usec /2 ) ;
     
        op1=rand() % LLONG_MAX ;
        /* set: 
         * op1 = - rand() % LLONG_MAX ; 
         * for help bugfix tests.
         * Thank's for your collaboration and your help.
         ******************************************/
     
        srand(tv.tv_usec / 5 ) ;
     
        op2=rand() % LLONG_MAX ;
        /* set: 
         * op2 = - rand() % LLONG_MAX ; 
         * for help bugfix tests.
         * Thank's for your collaboration and your help.
         ******************************************/
     
     
        memset(op1_str,'\0',128) ;
        memset(op2_str,'\0',128) ;
        inttobin(op1,op1_str) ;
        inttobin(op2,op2_str) ;
     
        if (! (op1 + op2 == binaddbin(op1_str,op2_str) ) ) {
          printf("bin add error\n") ;
          break ;
        }
        if (! (op1 - op2 == binsubbin(op1_str,op2_str)) ) {
          printf("bin sub error\n") ;
          break ;
        }
        if (! (op1 * op2 == binmultbin(op1_str,op2_str)) ) { 
          printf("bin mult error\n") ;
          break ;
        }
        if (! ((long double) op1 / (long double) op2 == bindivbin(op1_str,op2_str)) ) {
          printf("bin div error\n") ;
          break ;
        }
        printf("-------------------------------------------------------------\n") ;
     
     
        memset(op1_str,'\0',128) ;
        memset(op2_str,'\0',128) ;
        inttooct(op1,op1_str) ;
        inttooct(op2,op2_str) ;
        if (! (op1 + op2 == octaddoct(op1_str,op2_str) ) ) {
    	printf("oct add error\n") ;
    	break ;
          }
        if (! (op1 - op2 == octsuboct(op1_str,op2_str)) ) {
          printf("oct sub error\n") ;
          break ;
        }
        if (! (op1 * op2 == octmultoct(op1_str,op2_str)) ) { 
          printf("oct mult error\n") ;
          break ;
        }
        if (! ((long double) op1 / (long double) op2 == octdivoct(op1_str,op2_str)) ) {
          printf("oct div error\n") ;
          break ;
        }
     
        printf("-------------------------------------------------------------\n") ;
     
        memset(op1_str,'\0',128) ;
        memset(op2_str,'\0',128) ; 
        inttohex(op1,op1_str) ;
        inttohex(op2,op2_str) ;
        if (! (op1 + op2 == hexaddhex(op1_str,op2_str) ) ) {
    	printf("hex add error\n") ;
    	break ;
        }
        if (! (op1 - op2 == hexsubhex(op1_str,op2_str)) ) {
          printf("hex sub error\n") ;
          break ;
        }
        if (! (op1 * op2 == hexmulthex(op1_str,op2_str)) ) { 
          printf("hex mult error\n") ;
          break ;
        }
        if (! ((long double) op1 / (long double) op2 == hexdivhex(op1_str,op2_str)) ) {
          printf("hex div error\n") ;
          break ;
        }
     
        printf("-------------------------------------------------------------\n") ;
      }
      free(op1_str) ;
      free(op2_str) ;
      return ;
     
    }
    Vous pouvez certes me laisser a mon triste sort mais ça serai un homicide par négligence car la tête ne résiste pas longtemps propulser a de maintes reprises contre un mur.
    Je comprendrai.

    Il faut savoir que les fonctions sont très basiques ainsi que mon style et je pense que vous n'aurez pas de mal a me dire ou est le problème si je suis encore vivant d'ici la.
    Pour faire tes armes:
    Use du présent pour construire ton futur sinon use de ce que tu as appris auparavant.
    Et sois toujours bien armé avant de te lancer.
    Le hasard ne sourit qu'aux gens préparés...
    Site: Website programmation international (www.open-source-projects.net)
    Site: Website imagerie 3D (www.3dreaming-imaging.net)
    Testez aux moins pendant une semaine l'éditeur avec terminaux intégrées it-edit Vous l'adopterai sûrement !
    FUN is HARD WORK !!!

  2. #2
    Membre émérite
    Avatar de imperio
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2010
    Messages
    852
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2010
    Messages : 852
    Points : 2 298
    Points
    2 298
    Par défaut
    J'ai regarde tres vite fait et j'ai pas trouve ce qui clochait, je finirai de regarder ca quand j'aurai le temps et que je serai repose. En attendant je peux t'offrir de voir ou ca coince en comparant avec mon propre convertisseur de base (bases infinies et conversion avec toutes les bases que tu peux imaginer). Tu peux voir ca dans les sources que j'ai poste sur developpez, mais n'etant pas a jour, je te conseille plutot de jeter un coup d'oeil ici.

  3. #3
    Modérateur
    Avatar de jlliagre
    Homme Profil pro
    Ingénieur support avancé & développement
    Inscrit en
    Juin 2007
    Messages
    2 695
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur support avancé & développement
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 695
    Points : 7 882
    Points
    7 882
    Par défaut
    Est-ce que tu pourrais expliquer de manière plus précise quel est le problème que tu rencontres et comment le mettre en évidence ?

    J'ai compilé tes sources et l'exécution du binaire résultant produit 30000 lignes de "-------------------------------------------------------------" et rien d'autre, ce qui n'aide pas trop.
    ɹǝsn *sıɹɐlos*

  4. #4
    Modérateur

    Avatar de Bktero
    Homme Profil pro
    Développeur en systèmes embarqués
    Inscrit en
    Juin 2009
    Messages
    4 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur en systèmes embarqués

    Informations forums :
    Inscription : Juin 2009
    Messages : 4 481
    Points : 13 679
    Points
    13 679
    Billets dans le blog
    1
    Par défaut
    Je ne sais pas ce que contiennent ces fichiers, mais les inclure de cette manière me parait très douteux :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    #include "conversion/utils/conversion_utils.c" 
    #include "conversion/int_hex/calc_int_hex.c"
    #include "conversion/int_bin/calc_int_bin.c"
    #include "conversion/int_oct/calc_int_oct.c" 
     
     
    #include "conversion/float_to_bin/float_bin.c"
    #include "conversion/float_to_oct/float_oct.c"
    #include "conversion/float_to_hex/float_hex.c"
     
    #include "operations/int_result/calc_hex_int_operations.c"
    #include "operations/int_result/calc_oct_int_operations.c"
    #include "operations/int_result/calc_bin_int_operations.c"
     
    #include "operations/float_result/calc_hex_float_operations.c"
    #include "operations/float_result/calc_oct_float_operations.c" 
    #include "operations/float_result/calc_bin_float_operations.c"
    Une règle de bonne usage en C est de ne pas inclure des fichiers .c mais uniquement des fichiers .h. La gestion des "modules" en C passe par des unités de compilation (des .c) qui génèrent des .o et qu'on relie entre eux avec des .h pour que les symboles soient connus. C'est ensuite l'éditeur qui va réellement lié les modules entre eux. Rien à avoir avec la gestion des modules Python avec import.

  5. #5
    Membre expérimenté
    Avatar de Luke spywoker
    Homme Profil pro
    Etudiant informatique autodidacte
    Inscrit en
    Juin 2010
    Messages
    1 077
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Etudiant informatique autodidacte

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 077
    Points : 1 742
    Points
    1 742
    Par défaut
    Je pense avoir été assez clair concernant mon problème:
    les nombres négatifs sauf pour les float binaires ou cela fonctionne bizarrement,

    si vous aviez lu le fichiers hobdcalc.c vous aurez sûrement remarquer que la fonction main() ne peut appeler directement que 2 fonctions:

    float_operations_test() ;

    integer_operations_test() ;

    dont les lignes sont commentez.

    Dans ces fonctions il y toutes les assertions qui fonctionnent:
    addition, soustraction, multiplication et division.

    Et sous l'initialisation des variables de valeurs aléatoires qui fonctionnent,
    il y a en commenter la même initialisation mais avec des nombres négatifs (ce qui ne fonctionne pas et est le problème).

    Donc je me doute bien que vous n'êtes pas devins mais il faut décommenter les lignes du problème c.a.d les lignes avec les nombres négatif et éventuellement commenter les lignes générant les nombres positifs.

    Je pensait que présenter le problème avec des assertions qui fonctionnent puis en dessous une ligne effectuant la même initialisation avec un nombre négatif (ce qui ne fonctionne pas et est le problème) serai plus approprier.

    En bref:

    dans la fonction float_operations_test():
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     
    op1=(double) (rand() % (9223372036854775807/2)) / ((rand() % (9223372036854775807/2))+1) ;
    /* set: 
     * op1 = - (double) (rand() % (9223372036854775807/2)) / ((rand() % (9223372036854775807/2))+1) ; // (long double) not work !!!
     * for help bugfix tests.
     * Thank's for your collaboration and your help.
     ******************************************/
     
    /* ... */
     
    op2=(double) (rand() % (9223372036854775807/2)) / ((rand() % (9223372036854775807/2))+1) ;
    /* set: 
     * op2 = - (double) (rand() % (9223372036854775807/2)) / ((rand() % (9223372036854775807/2))+1) ; // (long double) not work !!!
     * for help bugfix tests.
     * Thank's for your collaboration and your help.
     ******************************************/
    op1 et op2 est sont a remplacer par:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    op1 = - (double) (rand() % (9223372036854775807/2)) / ((rand() % (9223372036854775807/2))+1) ; // (long double) not work !!! 
    op2 = - (double) (rand() % (9223372036854775807/2)) / ((rand() % (9223372036854775807/2))+1) ; // (long double) not work !!!
     /* Notez le signe moins en début de contenus de variable comme le dit le commentaire */
    Et dans la fonction integer_operations_test():
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     
    op1=rand() % LLONG_MAX ;
    /* set: 
     * op1 = - rand() % LLONG_MAX ; 
     * for help bugfix tests.
     * Thank's for your collaboration and your help.
     ******************************************/
     
    /* .. */
     
    op2=rand() % LLONG_MAX ;
    /* set: 
     * op2 = - rand() % LLONG_MAX ; 
     * for help bugfix tests.
     * Thank's for your collaboration and your help.
     ******************************************/
    op1 et op2 sont a remplacer par:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    op1 = - rand() % LLONG_MAX ; 
    op2 = - rand() % LLONG_MAX ;
    /* Notez le signe moins en début de contenus de variable comme le dit le commentaire */
    Vous verrez alors que cela ne fonctionne pas du tout.
    Désolé je ne peut être plus précis.

    Cordialement merci pour votre intérêt a mon problème.
    Pour faire tes armes:
    Use du présent pour construire ton futur sinon use de ce que tu as appris auparavant.
    Et sois toujours bien armé avant de te lancer.
    Le hasard ne sourit qu'aux gens préparés...
    Site: Website programmation international (www.open-source-projects.net)
    Site: Website imagerie 3D (www.3dreaming-imaging.net)
    Testez aux moins pendant une semaine l'éditeur avec terminaux intégrées it-edit Vous l'adopterai sûrement !
    FUN is HARD WORK !!!

  6. #6
    Modérateur
    Avatar de jlliagre
    Homme Profil pro
    Ingénieur support avancé & développement
    Inscrit en
    Juin 2007
    Messages
    2 695
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur support avancé & développement
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 695
    Points : 7 882
    Points
    7 882
    Par défaut
    Citation Envoyé par Luke spywoker Voir le message
    Je pense avoir été assez clair concernant mon problème:
    Pas tellement ...

    les nombres négatifs sauf pour les float binaires ou cela fonctionne bizarrement,
    C'est à dire ??
    Ca ne compile pas ?
    Ca compile mais ne fonctionne pas comme prévu ? Dans ce dernier cas, quel est le résultat obtenu par rapport au résultat attendu ?

    si vous aviez lu le fichiers hobdcalc.c vous aurez sûrement remarquer que la fonction main() ne peut appeler directement que 2 fonctions:
    Non, je ne l'avais pas remarqué car le fichier hobdcalc.c présent sur dans l'archive qui contient les sources n'est pas le même que celui posté dans la question ...

    Merci de poster un fichier hobdcalc.c mettant en évidence le problème rencontré sans que l'on ait besoin de l'éditer.
    ɹǝsn *sıɹɐlos*

  7. #7
    Membre expérimenté
    Avatar de Luke spywoker
    Homme Profil pro
    Etudiant informatique autodidacte
    Inscrit en
    Juin 2010
    Messages
    1 077
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Etudiant informatique autodidacte

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 077
    Points : 1 742
    Points
    1 742
    Par défaut
    J'ai finalement réussi a coder les nombres négatifs,

    et j'ai mis les fonctions de conversion et de calcul a disposition de tous dans la section contribuez.


    hobdcalc: fonctions de conversion et de calcul en base 12, 8, 2, 10.
    Pour faire tes armes:
    Use du présent pour construire ton futur sinon use de ce que tu as appris auparavant.
    Et sois toujours bien armé avant de te lancer.
    Le hasard ne sourit qu'aux gens préparés...
    Site: Website programmation international (www.open-source-projects.net)
    Site: Website imagerie 3D (www.3dreaming-imaging.net)
    Testez aux moins pendant une semaine l'éditeur avec terminaux intégrées it-edit Vous l'adopterai sûrement !
    FUN is HARD WORK !!!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Tableaux] Casse têtes de boucles
    Par Anduriel dans le forum Langage
    Réponses: 5
    Dernier message: 28/06/2006, 00h24
  2. Casse tête chinois
    Par Jahjouh dans le forum Algorithmes et structures de données
    Réponses: 3
    Dernier message: 15/03/2006, 09h04
  3. requête SQL un peu casse tête
    Par hellbilly dans le forum Langage SQL
    Réponses: 4
    Dernier message: 15/12/2005, 10h03
  4. Classe, pile, pointeurs et casse-tête!
    Par zazaraignée dans le forum Langage
    Réponses: 6
    Dernier message: 26/09/2005, 16h57
  5. casse-tête excel
    Par gregius dans le forum Access
    Réponses: 2
    Dernier message: 21/09/2005, 16h38

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo