コード例 #1
0
 public void DoubleSerialization()
 {
     string doubleStr    = "10001";
     var    doubleBytes  = SerializationHelper.DecimalToBinary(8, doubleStr);
     var    doubleBytes2 = BitConverter.GetBytes(Convert.ToUInt64(doubleStr));
     var    doubleResStr = SerializationHelper.BinaryToDecimal(doubleBytes);
 }
コード例 #2
0
        public void DecimalSerialization()
        {
            string decimalStr   = "10001";
            var    decimalBytes = SerializationHelper.DecimalToBinary(16, decimalStr);

            Int32[]     bits  = decimal.GetBits(Convert.ToDecimal(decimalStr));
            List <byte> bytes = new List <byte>();

            foreach (Int32 i in bits)
            {
                bytes.AddRange(BitConverter.GetBytes(i));
            }
            var decimalBytes2 = bytes.ToArray();

            var decimalResStr = SerializationHelper.BinaryToDecimal(decimalBytes);
        }
コード例 #3
0
        private static void WriteUInt128(MemoryStream ms, object value)
        {
            var decimalBytes = SerializationHelper.DecimalToBinary(16, value.ToString());

            ms.Write(decimalBytes, 0, decimalBytes.Length);
        }