Example #1
0
 public static string ToStringDec(Bt[] a)
 {
     if (BitTools.IsKnown(a))
     {
         return(BitTools.GetUlongValue(a) + "");
     }
     //TODO:
     throw new Exception();
 }
Example #2
0
        public static string ToStringBin(Bt[] a)
        {
            StringBuilder sb = new StringBuilder("0b");

            for (int i = (a.Length - 1); i >= 0; --i)
            {
                sb.Append(BitTools.BitToChar(a[i]));
                if ((i > 0) && (i != a.Length - 1) && (i % 8 == 0))
                {
                    sb.Append('.');
                }
            }
            return(sb.ToString());
        }
Example #3
0
        public static string ToStringHex(Bt[] a)
        {
            if ((a.Length % 4) != 0)
            {
                Console.WriteLine("WARNING: toStringHex: found odd number of bits:" + a.Length);
                return("");
            }
            StringBuilder sb     = new StringBuilder("0x");
            int           nChars = a.Length >> 2;

            for (int j = (nChars - 1); j >= 0; --j)
            {
                int offset = (j << 2);
                sb.Append(BitTools.BitToCharHex(a[offset], a[offset + 1], a[offset + 2], a[offset + 3]));

                if ((j > 0) && ((j % 8) == 0))
                {
                    sb.Append('.');
                }
            }
            return(sb.ToString());
        }