i could simply do the 5cl / 10H2 = 0.5 HCl , so 50%
in a formula it would be.. a/b = c , which a must be the minor number..
but because i dont want any hand of man here, i must make the expression by it self tell which is the minor and minor...

For that i will use a genetic Approach, by Mendel.

if we have the specie A and B, being A a pure genotype and b a pure genotype, it would be 2DNA strands so 2 alleles for each chromossome.
Because im using pure reactants, like H2 or Cl , they are pure .. so AA and BB, HCl is Hybrid, (AB)
thus, AA x BB this will give an offspring of combination of

1AA + 1 BB + 2AB ( or more specifc 1 AB + 1 BA).
Ok so now that i know this... i can put this into the formula and purpose and intermediary algebra expression where i put this genetic heritage thing...

i will call it R(genotype). And there will be 4 of this.

R(genotype) : R(ab) , R(aa), R(bb) and R(ba).

if i make R=sign(alele 1 - oposite alele 1)X alele2.. i will get this distribution of R alele 1, alele2...
Raa=sign(a-b)x a
Rab=sign(a-b)x b
Rbb=sign(b-a)x b
Rba=sign(b-a)x a

filtering the negative values to be zero, and out of the add:

Raa=(1+sign(a-b))* a;
Rab=(1+sign(a-b))* b;
Rbb=(1+sign(b-a))* b;
Rba=(1+sign(b-a))* a;

now that i got the R function i can compose it on another function, that will determine which value is the lower one by its own.

%= ( ( (Rba/2) + (Rab/2)) / ((Raa/2) + (Raa/2) ))*100


The lite-c function final is this:

function percent(var a, var b){

var Rab,Rbb,Raa,Rba;
Raa=(1+sign(a-b))* a;
Rab=(1+sign(a-b))* b;
Rbb=(1+sign(b-a))* b;
Rba=(1+sign(b-a))* a;
return((((Rba/2)+(Rab/2))/((Raa/2)+(Rbb/2)))*100);
}


function main(){
var reacting_p=percent(5,10);
var reacting_p=percent(5,5);
var reacting_p=percent(10,5); // the inverse, function will determine the minor number and major automatically.

}


all this to avoid using If minor then ... in a single expressiong..

Perhaps theres a batter way, but i just came up with this and it works so..

Last edited by MMike; 10/24/09 20:42.