Salut ,
Je veux faire des fonctions qui marchent sur des numeros stocke sous la forme d'un structure . cette derniere contiens 4 champs un vecteur chiffres , signe 0 positif ou 1 negatif et le nrc qui est numero de chiffres total et nrd le numero de chiffres apres la virgule
par exemple
le numero +12345.345
nr.chiffres=[1 2 3 4 5 3 4 5 ]
nr.nrc=8
nr.nrd=3
nr.signal=0

je veux realiser les fonction

function [quotient,reste] = div_quotientreste(nr1,nr2);
une fonction qui retourne le quotien et le reste de nr1/nr2

function resultat = div_decimal(nr1,nr2)
elle retourne le quotient avec 2 numeros apres la virgule
function resultat = radical(nr1)
qui calcule le radical carre d'un numero sans virgule et positif


ayant les fonctions

function resultat = addition(nr1, nr2)
function resultat = soustraction(nr1,nr2)
function resultat = multi_chiffre(nr1,chiffre)
function resultat = multi_nr(nr1,nr2)

j'ai essaye pour

function [quotient,reste] = div_quotientreste(nr1,nr2)
function resultat = div_decimal(nr1,nr2)
mais ca marche pas (syntax, meme algorithme pas bien travaille )

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
function [cat,rest] = imp_catrest(nr_mare1,nr_mare2)
% determinarea semnului   
 
 
rest.cifre = (1,:) 
j=1
k=1
function [cat,rest]=divide(nr_mare1,nr_mare2)
for  i= [1:nr_mare1]
	rest.cifre(i)=nr_mare1.cifre(i)
	o=i;
	if ((rezu=compara(rest,nr_mare2.cifre))==1)
		i++;
	endif
	i=o;
	while ((rez=compara(inm_cifra(nr_mare2,j),rest))==1)
		j++;
	endwhile
	cat.cifre(k)=j;
	k++;
	rest=scadere(temp,inm_cifra(nr_mare2,j))
	j=0;
	i++;	
	[cat,rest]=divide(rest,nr_mare2)
 
endfor
endfunction
 
	if nr_mare1.semn == 0 && nr_mare2.semn == 0
		cat.semn = 0; 
		rest.semn = 0;
	elseif nr_mare1.semn == 0 && nr_mare2.semn == 1
		cat.semn = 1;
		rest.semn = 0;
	elseif nr_mare1 == 1 && nr_mare2.semn == 0
		cat.semn = 0;
		rest.sem = 1;
	elseif nr_mare1.semn == 1 && nr_mare2.semn == 1 
		cat.semn = 0;
		rest.sem = 1;
	endif 
 
rest.nrc=length(rest.cifre);
cat.nrc=length(cat.cifre);
endfunction
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
function rezultat = imp_zecimale(nr_mare1,nr_mare2)
 
[cat,rest] = imp_catrest(nr_mare1,nr_mare2)
	aux=zeros(2+length(rest.cifre))(1,:)
	aux(1:length(rest.cifre)-2,rest.cifre)=rest.cifre
	rest.cifre=aux
	[cat2,rest2]=imp_catrest(rest,nr_mare2)
	cat.cifre(length(cat.cifre)+1)=cat2.cifre(1);
	cat.cifre(length(cat.cifre)+2)cat2.cifre(2);
	rezultat.cifre=cat.cifre;
	rezultat.nrc=length(rezultat.cifre);
if rezultat.cifre(rezultat.nrc)==0
	rezultat.cifre(rezultat.nrc)=[]
	rezultat.nrc -- ;
if rezultat.cifre(rezultat.nrc-1)
	rezultat.cifre(rezultat.nrc-1)=[]
	rezultat.nrc--;
endif
endif
 
 
 
% determinam semnele  
 
if nr_mare1.semn == 0 && nr_mare2.semn == 0
	rezultat.semn = 0; 
elseif nr_mare1.semn == 0 && nr_mare2.semn == 1
	rezultat.semn = 1;
elseif nr_mare1 == 1 && nr_mare2.semn == 0
	rezultat.semn = 0;
elseif nr_mare1.semn == 1 && nr_mare2.semn == 1 
	rezultat.semn = 0;
endif 
 
endfunction
Merci d'avance