468,771 Members | 1,965 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

How to convert a Byte array to a double array???

hi people.

I have to acess a database, and there are some fields that
are binary. when i acess that field is read like an array
of bytes.

but in reality it's an array of doubles!!!

how can i convert from a byte array to a double array?

ps: in C this is SO easy
Nov 20 '05 #1
2 7934
Try this out:

Dim test() As Byte = {23, 45, 78, 98, 101, 157, 158, 162, 178}

Dim dble(8) As Double

Array.Copy(test, dble, 9)

"antonio matos" <an*******@discussions.microsoft.com> wrote in message
news:0d****************************@phx.gbl...
hi people.

I have to acess a database, and there are some fields that
are binary. when i acess that field is read like an array
of bytes.

but in reality it's an array of doubles!!!

how can i convert from a byte array to a double array?

ps: in C this is SO easy

Nov 20 '05 #2

Also, if you want to change 8 bytes into a double you can you the
Bitcoverter class:

Dim j() As Byte = {2, 4, 78, 12, 99, 111, 45, 156}
Dim r As Double = BitConverter.ToDouble(j, 0)
Or , you can put this into a loop to covert a Byte array to double values.

Dim m as Integer = j.Length \ 8
Dim dble(m-1) as Double
Dim k as Integer = 0

For i = 0 to j.Length -1 Step 8

dble(k)= BitConverter.ToDouble(j, i)
k +=1

Next
"Brian" <no****@prairie.lakes.com> wrote in message
news:vr************@corp.supernews.com...
Try this out:

Dim test() As Byte = {23, 45, 78, 98, 101, 157, 158, 162, 178}

Dim dble(8) As Double

Array.Copy(test, dble, 9)

"antonio matos" <an*******@discussions.microsoft.com> wrote in message
news:0d****************************@phx.gbl...
hi people.

I have to acess a database, and there are some fields that
are binary. when i acess that field is read like an array
of bytes.

but in reality it's an array of doubles!!!

how can i convert from a byte array to a double array?

ps: in C this is SO easy


Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by matt melton | last post: by
15 posts views Thread by jeko | last post: by
5 posts views Thread by kevinniu | last post: by
6 posts views Thread by Ricardo Quintanilla | last post: by
6 posts views Thread by Dennis | last post: by
1 post views Thread by Paul Jarvis | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.