473,320 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 9240
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: matt melton | last post by:
Hi there, I am trying to write a method that accepts an array of any primitive type and will return the same array without copying memory as an array of bytes. ie. I'd like to be able to do...
15
by: jeko | last post by:
Hi, is it possible to read a double variable one byte at a time. I would want store each byte into unsigned char and then assemble again the double variable again. thanx Andrea
5
by: kevinniu | last post by:
Hi everyone, In c#, what is the fastest way(include unsafe) to convert a array of bytes(which really contains the bytes of a double array) to a arry of double. thanks
6
by: Ricardo Quintanilla | last post by:
i have a code that sends data to a socket listening over as400 platform, the socket responds to me as a "byte array". then i need to convert the "byte array" into a string. the problem is that...
3
by: MuZZy | last post by:
Hi, I just wonder if someone can help me wit this - i have a byte array and need to convert it to short array, creating short numbers by combining bytes by pairs: My array: byte, byte, byte,...
6
by: Dennis | last post by:
I was trying to determine the fastest way to build a byte array from components where the size of the individual components varied depending on the user's input. I tried three classes I built: (1)...
6
by: moondaddy | last post by:
I'm writing an app in vb.net 1.1 and need to convert a byte array into a string, and then from a string back to a byte array. for example Private mByte() as New Byte(4){11,22,33,44} Now how...
1
by: Paul Jarvis | last post by:
I have a large structure, below is a simplistic version of my structure: public struct MeanMinMaxSd { public double mean; public double min; public double max; public double sd; }
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.