示例#1
0
        /// <summary>
        /// 从字节数组中获取16位浮点数字
        /// </summary>
        /// <param name="type">处理器类型</param>
        /// <param name="data">字节数组</param>
        /// <param name="startIndex">数据起始位置</param>
        /// <returns>16位浮点数字</returns>
        internal static Int16 ToInt16(C3DProcessorType type, Byte[] data, Int32 startIndex)
        {
            if (C3DBitConverter.IsNeedReverse(type))
            {
                Array.Reverse(data, startIndex, 2);
            }

            return(BitConverter.ToInt16(data, startIndex));
        }
示例#2
0
        /// <summary>
        /// 返回给定数据的字节数组
        /// </summary>
        /// <param name="value">32位单精度浮点型</param>
        /// <returns>字节数组</returns>
        internal static Byte[] GetBytes(Single value)
        {
            Byte[] data = BitConverter.GetBytes(value);

            if (C3DBitConverter.IsNeedReverse(C3DConstants.FILE_DEFAULT_PROCESSOR_TYPE))
            {
                Array.Reverse(data, 0, 4);
            }

            return(data);
        }
示例#3
0
        /// <summary>
        /// 从字节数组中获取32位单精度浮点数字
        /// </summary>
        /// <param name="type">处理器类型</param>
        /// <param name="data">字节数组</param>
        /// <param name="startIndex">数据起始位置</param>
        /// <returns>32位单精度浮点数字</returns>
        internal static Single ToSingle(C3DProcessorType type, Byte[] data, Int32 startIndex)
        {
            if (C3DBitConverter.IsNeedReverse(type))
            {
                Array.Reverse(data, startIndex, 4);
            }

            if (type == C3DProcessorType.DEC)
            {
                return(new VAXSingle(data, startIndex).ToSingle());
            }
            else
            {
                return(BitConverter.ToSingle(data, startIndex));
            }
        }