Mathc initiation/001A
Apparence
Cette méthode permet aussi d'effectuer une conversion rapide d'un nombre écrit en base 16 en écriture en base 10. Voici un nombre écrit, en base 16.
#A = 10 #D = 13
Exemple : #15AACF7 #B = 11 #E = 14
#C = 12 #F = 15
Ce nombre vaut : #15AACF7 = +22 719 735
1 (16**6) + 5 (16**5) + A (16**4) + A (16**3) + C (16**2) + F (16) + 7 =
1 (16**6) + 5 (16**5) + 10 (16**4) + 10 (16**3) + 12 (16**2) + 15 (15) + 7 =
#15AACF7 = +22 719 735
Il s'agit de l'évaluation d'un polynôme. Le résultat est le reste de la division synthétique.
Installer et compiler ces fichiers dans votre répertoire de travail.
c01a.c |
|---|
/* ---------------------------------- */
/* save as c01a.c 15AACF7 */
/* ---------------------------------- */
#include "x_a.h"
/* ---------------------------------- */
# define DEGREE 6
# define COEFF_NB DEGREE + 1
/* ---------------------------------- */
int main(void)
{
double k = 16;
double remainder;
double *Pa = I_Px( COEFF_NB);
double *Pt = I_Px( COEFF_NB);
double *Pqr = I_Px( COEFF_NB);
double *Pq = I_Px((COEFF_NB-1));
double a[COEFF_NB] = {1,5,10,10,12,15,7};
clrscrn();
printf(" Using this method, you can quickly convert\n"
" a number written in base 16 to base 10.\n\n"
" In fact, if a number is written in base 16.\n"
" #A = 10 #D = 13\n"
" Example : #15AACF7 #B = 11 #E = 14\n"
" #C = 12 #F = 15\n\n"
" this number is worth : #15AACF7 = +22.719.735\n\n"
" 1(16**6)+5(16**5)+ A(16**4)+ A(16**3)+ C(16**2)+ F(16)+7 =\n"
" 1(16**6)+5(16**5)+10(16**4)+10(16**3)+12(16**2)+15(15)+7 ="
" +22.719.735\n\n"
" This is therefore the evaluation of a polynomial,\n"
" it is the remainder of the synthetic division.\n\n\n");
stop();
clrscrn();
c_a_Px(a,Pa);
printf("\n If P(x) is : \n\n ");
p_Px(Pa);printf(" = 0\n\n");
printf(" If we divide P(x) by : [x-(%+.0f)] \n\n",k);
remainder = compute_horner(k,Pa,Pt,Pqr,Pq);
p_horner(Pa,Pt,Pqr);printf("\n");
printf(" The synthetic division indicates that P(%+.0f) = %+.0f\n\n\n",
k, remainder);
stop();
free(Pa);
free(Pt);
free(Pqr);
free(Pq);
return 0;
}
/* ---------------------------------- */
/* ---------------------------------- */
Exemple de sortie écran :
Using this method, you can quickly convert
a number written in base 16 to base 10.
In fact, if a number is written in base 16.
#A = 10 #D = 13
Example : #15AACF7 #B = 11 #E = 14
#C = 12 #F = 15
this number is worth : #15AACF7 = +22.719.735
1(16**6)+5(16**5)+ A(16**4)+ A(16**3)+ C(16**2)+ F(16)+7 =
1(16**6)+5(16**5)+10(16**4)+10(16**3)+12(16**2)+15(15)+7 = +22.719.735
This is therefore the evaluation of a polynomial,
it is the remainder of the synthetic division.
Press return to continue.
If P(x) is :
+ x**6 +5x**5 +10x**4 +10x**3 +12x**2 +15x +7 = 0
If we divide P(x) by : [x-(+16)]
+1 +5 +10 +10 +12 +15 +7
+0 +16 +336 +5536 +88736 +1419968 +22719728
--------------------------------------------------------
+1 +21 +346 +5546 +88748 +1419983 +22719735
The synthetic division indicates that P(+16) = +22719735
Press return to continue.