public static Gena DecimalToBinary(int dec)
        {
            List <int> bools = new List <int>()
            {
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0
            };

            string s = Convert.ToString(dec, 2);
            var    j = s.Length - 1;

            for (int i = bools.Count - 1; i >= 0 && j >= 0; i--)
            {
                bools[i] = s[j] - 48;
                j--;
            }

            var g = new Gena(bools);

            return(g);
        }
        public static int BinaryToDecimal(Gena binary)
        {
            var deca = 0;

            deca = Convert.ToInt32(binary.ToString(), 2);
            return(deca);
        }
Example #3
0
 public void Reglare()
 {
     if (Config.BinaryToDecimal(Gena) >= Config.SizeDomeniu2)
     {
         var deca = Config.BinaryToDecimal(Gena);
         var mod  = deca % (Config.SizeDomeniu2);
         this.Gena = Config.DecimalToBinary(mod);
     }
     if (Config.BinaryToDecimal(Gena2) >= Config.SizeDomeniu2)
     {
         var deca = Config.BinaryToDecimal(Gena2);
         var mod  = deca % (Config.SizeDomeniu2);
         this.Gena2 = Config.DecimalToBinary(mod);
     }
 }
Example #4
0
 public override string ToString()
 {
     return(Gena.ToString());
 }
Example #5
0
 public void CreateRandom()
 {
     Gena.CreateRandom();
     Reglare();
 }
Example #6
0
 public Cromozom()
 {
     Gena  = new Gena();
     Gena2 = new Gena();
 }