Template:Showfacts set ancestors/convert/doc

Purpose: Given a article name and an ahnentafel number in parens, this stores the pair converted for the generation immediately following. The function detects duplicate values (but non operational since it employs unused paramater 2? (This function was formerly Convert ahn.)

Parameters:
 * 1 = an article with ahnentafel as extracted from the ahnentafel property eg: Gerrit Jan te Kolstee (1758-1797) (4)
 * motherside = 1 if the tree is from the mother's side of the family. Default is zero (father's side).

How this black box works on the inside
For folks into math: we use a log function to derive the generation corresponding to the power of 2 base of the ahnentafel number. Upshifting or down shifting a generation is then a trivial operation.

For non math folks: Here is an illustration of how the number conversion works. First, examine the patterns of progression in ahnentafel numbers:
 * Gen0 Adam 1
 * Gen1 Adam 2; Eve 3; child's ancestors: = 2^1 (+1)
 * Gen2 Adam 4; Eve 5; Fred 6; Ethyl 7; Darren 2; Samantha 3 ancestors: take Gen1, father side and add 2, mother side add 4.
 * Gen3 Adam 8; eve 9 Fred 10; Ethyl 11; Derwood 4; Samantha 5
 * Gen3 (adam on mother's side:) Adam 12 Eve 13 Fred 14 Ethyl 15....


 * Generalization of pattern:
 * If ahn <4 add 2^1 if male, +2^2 if female
 * If ahn <8 add 2^2 if male, +2^3 if female
 * If ahn <2^4 add 2^3 if male, +2^4 if female
 * Refined: note the centrality of the generation#. The general rule is you always add 2^generation number if the tree is from the father, and add 2^(generation number+1) if from the mother. So how do we derive it. Ok finding the exponent of 2 is a log base 2 transform.  #expr has logN (ln), so we can do this.  To get log2 from ln, multiply 1/ln(2) times the ln of the ahn# and you have the log base 2.  ln(2) is about 1.44 so we just multiply with that and round down to the nearest integer.  That's your generation number (exp2base)
 * Formulas: exp2base= floor( ln(AHN)*1.44 ) btw- floor means round down to the greatest integer less than x
 * ahn=1734, generation =
 * adding 1734 from a father's tree becomes
 * adding 1734 from a mother's tree becomes
 * calculation:  
 * this power of 2 "exp2base" number is just another word for Generation #.