Exemplo n.º 1
0
        /// <summary>
        /// Returns a single-precision floating point number converted from four bytes at a specified position in a byte array.
        /// </summary>
        /// <param name="value">An array of bytes.</param>
        /// <param name="startIndex">The starting position within value.</param>
        /// <returns>A single-precision floating point number formed by four bytes beginning at <paramref name="startIndex"/>.</returns>
        public static float ToSingle(byte[] value, int startIndex)
        {
            BitConverterServices.ValidateToArguments(value, startIndex, 4);

            return(BitConverterEx.Int32BitsToSingle(ToInt32(value, startIndex)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fills the array with four bytes of the specified single-precision floating point value beginning at <paramref name="startIndex"/>.
        /// </summary>
        /// <param name="value">The number to convert.</param>
        /// <param name="buffer">The array of bytes to store converted value at.</param>
        /// <param name="startIndex">The start index where converted value is to be stored at <paramref name="buffer"/>.</param>
        public static void FillBytes(float value, byte[] buffer, int startIndex)
        {
            BitConverterServices.ValidateFillArguments(buffer, startIndex, 4);

            FillBytes(BitConverterEx.SingleToInt32Bits(value), buffer, startIndex);
        }