Numerical Conversions:

Let's convert base-10 "decimal fractions" to base-2 "fractions".  For instance, 0.5 in base-10 converts to 0.1 in base-2.  And 0.11 in base-2 converts to 0.75 in base-10.

1.  Create the function Conv_Frac_10_2(s10) that will convert a base-10 number between 0 and 1, in string-form, of the form ".dddddd" where 0<=d<=9 into a string-form number fraction in base-2.  Since the representation in base-2 of a fraction in base-10 is longer in number of digits, you should produce approx. log(10)/log(2) number of digits in base-2 for each digit in base 10.  In other words, if you're given 5 digits in base-10 (e.g, ".15726") you should produce 5 * log(10) / log(2) = 16 digits in base-2: 

Conv_Frac_10_2(".15726") -> ".0010100001000010"
Conv_Frac_10_2(".75") -> ".110000"

 

2. Create the function Conv_Frac_2_10(s2) which will convert a base-2 fraction to a base-10 fraction (both in string form).  The number of base-10 digits returned should be approx. log(2)/log(10) times the number of input base-2 digits:

Conv_Frac_2_10(".1100") -> ".75"
Conv_Frac_2_10(".0010100001000010") -> ".15725"