public static bool TryParse(string number, out KataFloat32 kataFloat)
        {
            kataFloat = new KataFloat32();

            // Find seperator
            var pattern = @"^(-{0,1})(\d+)\.{0,1}(\d*)$";
            var match   = Regex.Match(number, pattern);

            if (match.Length == 0)
            {
                return(false);
            }

            var sign = match.Groups[0].Value;

            kataFloat._sign = sign != "-" ? 0 : 1;

            //3.14                    #
            //3/2 = 1.5     1         #     0.14 * 2 = 0.28     0
            //1/2  = 0.5    1         #     0.28 * 2 = 0.56     0
            //0/2 = 0       0         #     0.56 * 2 = 1.12     1......
            //                        #     0.12 * 2 = 0.24
            //11.001

            //0.3535       0.3453453535123 * 2

            // 0.14 * 2 = 0.28
            // 0.28 * 2 = 0.56
            // 0.56 * 2 = 1.12
            // 0.12 * 2 = 0.24
            // 0.24 * 2 = 0.48
            // 0.48 * 2 = 0.96
            // 0.96 * 2 = 1.84
            // 0.84 * 2 = 1.68

            var intergralInput = match.Groups[1].Value;

            int.TryParse(intergralInput, out int intergral);

            var intergralBinaryList = GetIntergralBinary(intergral);

            var fractionalInput = match.Groups[2].Value;
            var orderDelter     = GetOrderDelter();

            if (fractionalInput.Length > 8)
            {
                fractionalInput = fractionalInput.Substring(0, 8); //keep string less than 9 due to int32 constraints
            }

            int.TryParse(fractionalInput, out int fractional);
            var faractionalBinaryList = GetFractionalBinary(fractional);
        }
Beispiel #2
0
 public static string ZYX(KataFloat32 x)
 {
     Console.WriteLine($"I are the bestest katafloat");
     return(x.ToString());
 }
Beispiel #3
0
 public static void XYZ(KataFloat32 x)
 {
     x       = new KataFloat32();
     x._sign = 4;
 }