示例#1
0
        public void TestDoubleLong()
        {
            var obj = new DoubleLong {
                L1 = 1, L2 = 2
            };

            Assert.AreEqual(DoubleLong.DebuggerSize, obj.GetExclusiveSize());
        }
        /// <summary>
        /// Converts double value into string representation of a real number in the format IEEE 754
        /// </summary>
        /// <param name="value"> Value for converting </param>
        /// <returns> String representation of a real number in the format IEEE 754 </returns>
        public static string ToBinaryString(this double value)
        {
            var result = new DoubleLong();

            result.AsDouble = value;

            return(GetBitsString(result.AsLong));
        }
示例#3
0
        /// <summary>
        /// Extension method which converts passed double value to its string IEEE representation.
        /// </summary>
        /// <param name="number">
        /// Double value for converting.
        /// </param>
        /// <returns>
        /// String IEEE representation of passed value.
        /// </returns>
        public static string ConvertToIEEE(this double number)
        {
            string doubleIEEE         = string.Empty;
            long   longRepresentation = new DoubleLong(number).LongValue;

            for (int i = 0; i < NumOfBits; i++)
            {
                doubleIEEE          += (longRepresentation & 1) == 1 ? "1" : "0";
                longRepresentation >>= 1;
            }

            return(new string(doubleIEEE.Reverse().ToArray()));
        }
示例#4
0
        private void _parse()
        {
            _datatype = ((DataType)m_io.ReadU1());
            switch (Datatype)
            {
            case DataType.Integer:
            {
                _dataValue = new Integer(m_io, this, m_root);
                break;
            }

            case DataType.Unsigned:
            {
                _dataValue = new Unsigned(m_io, this, m_root);
                break;
            }

            case DataType.Long:
            {
                _dataValue = new Long(m_io, this, m_root);
                break;
            }

            case DataType.Boolean:
            {
                _dataValue = new Boolean(m_io, this, m_root);
                break;
            }

            case DataType.Structure:
            {
                _dataValue = new Structure(m_io, this, m_root);
                break;
            }

            case DataType.Array:
            {
                _dataValue = new Array(m_io, this, m_root);
                break;
            }

            case DataType.Float64:
            {
                _dataValue = new Float64(m_io, this, m_root);
                break;
            }

            case DataType.DoNotCare:
            {
                _dataValue = new DoNotCare(m_io, this, m_root);
                break;
            }

            case DataType.LongUnsigned:
            {
                _dataValue = new LongUnsigned(m_io, this, m_root);
                break;
            }

            case DataType.Time:
            {
                _dataValue = new Time(m_io, this, m_root);
                break;
            }

            case DataType.OctetString:
            {
                _dataValue = new OctetString(m_io, this, m_root);
                break;
            }

            case DataType.NullData:
            {
                _dataValue = new NullData(m_io, this, m_root);
                break;
            }

            case DataType.CompactArray:
            {
                _dataValue = new CompactArray(m_io, this, m_root);
                break;
            }

            case DataType.DateTime:
            {
                _dataValue = new DateTime(m_io, this, m_root);
                break;
            }

            case DataType.DoubleLongUnsigned:
            {
                _dataValue = new DoubleLongUnsigned(m_io, this, m_root);
                break;
            }

            case DataType.Float32:
            {
                _dataValue = new Float32(m_io, this, m_root);
                break;
            }

            case DataType.Long64Unsigned:
            {
                _dataValue = new Long64Unsigned(m_io, this, m_root);
                break;
            }

            case DataType.DoubleLong:
            {
                _dataValue = new DoubleLong(m_io, this, m_root);
                break;
            }

            case DataType.Long64:
            {
                _dataValue = new Long64(m_io, this, m_root);
                break;
            }

            case DataType.Date:
            {
                _dataValue = new Date(m_io, this, m_root);
                break;
            }

            case DataType.Enum:
            {
                _dataValue = new Enum(m_io, this, m_root);
                break;
            }

            case DataType.Bcd:
            {
                _dataValue = new Bcd(m_io, this, m_root);
                break;
            }

            case DataType.VisibleString:
            {
                _dataValue = new VisibleString(m_io, this, m_root);
                break;
            }

            case DataType.BitString:
            {
                _dataValue = new BitString(m_io, this, m_root);
                break;
            }
            }
        }