C# BitConverter ToDouble
Description
BitConverter ToDouble
returns a double-precision floating
point number converted from eight bytes at a specified position in a byte
array.
Syntax
BitConverter.ToDouble
has the following syntax.
public static double ToDouble(
byte[] value,
int startIndex
)
Parameters
BitConverter.ToDouble
has the following parameters.
value
- An array of bytes.startIndex
- The starting position within value.
Returns
BitConverter.ToDouble
method returns A double precision floating point number formed by eight bytes beginning
at startIndex.
Example
The following code example converts elements of Byte arrays to Double values with the ToDouble method.
/*w w w.jav a2 s .c om*/
using System;
class BytesToDoubleDemo
{
public static void Main()
{
byte[ ] bytes = {
202, 192, 243, 63, 82, 211, 187, 188, 232, 126,
61, 126, 255, 255, 255, 255, 255, 255, 239, 255,
255, 255, 255, 255, 255, 239, 127, 1, 0, 0,
0, 240, 127 };
double value = BitConverter.ToDouble( bytes, 2 );
Console.WriteLine(value );
}
}
The code above generates the following result.