Byte array for double conversion in C #

I have an array of three bytes, I want to convert the array to double using C #. Please help me.

+3
source share
3 answers

Well double is an array of 8 bytes, so with 3 bytes you will not have all the possible values.

To do what you want:

var myBytes[] = {0,0,0,0,0,1,1,2}; //assume you pad your array with enough zeros to make it 8 bytes.
var myDouble = BitConverter.ToDouble(myBytes,0);
+2
source

Well, it depends on what you want to do.

8 ( ) double BitConverter.ToDouble, , - , double 64 , . ? , ? , .

+4

Depends on what exactly is stored in bytes, but you can just put an array with 5 bytes containing 0, and then use BitConverter. ToDouble .

+2
source

Source: https://habr.com/ru/post/1758337/


All Articles