PC Review


Reply
Thread Tools Rate Thread

(urgent) Binary data to byte[] array

 
 
=?Utf-8?B?WWFtYQ==?=
Guest
Posts: n/a
 
      8th Apr 2005
Hi,

I have the following binary data:

0x800006000000

which is equivalent to the followin

byte[] bytes = new byte[6];
bytes[0] = 0x80;
bytes[1] = 0x00;
bytes[2] = 0x06;
bytes[3] = 0x00;
bytes[4] = 0x00;
bytes[5] = 0x00;

How can I parse the binary to the quivalent byte array?

Thanks,

Yama



 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      8th Apr 2005
Yama <(E-Mail Removed)> wrote:
> I have the following binary data:
>
> 0x800006000000


As what?

> which is equivalent to the followin
>
> byte[] bytes = new byte[6];
> bytes[0] = 0x80;
> bytes[1] = 0x00;
> bytes[2] = 0x06;
> bytes[3] = 0x00;
> bytes[4] = 0x00;
> bytes[5] = 0x00;
>
> How can I parse the binary to the quivalent byte array?


It would help if you could give more details. When you say you have the
data, what format do you have it in? A long? A string?

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
 
=?Utf-8?B?WWFtYQ==?=
Guest
Posts: n/a
 
      8th Apr 2005
800006000000 = string

"Jon Skeet [C# MVP]" wrote:

> Yama <(E-Mail Removed)> wrote:
> > I have the following binary data:
> >
> > 0x800006000000

>
> As what?
>
> > which is equivalent to the followin
> >
> > byte[] bytes = new byte[6];
> > bytes[0] = 0x80;
> > bytes[1] = 0x00;
> > bytes[2] = 0x06;
> > bytes[3] = 0x00;
> > bytes[4] = 0x00;
> > bytes[5] = 0x00;
> >
> > How can I parse the binary to the quivalent byte array?

>
> It would help if you could give more details. When you say you have the
> data, what format do you have it in? A long? A string?
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
>

 
Reply With Quote
 
=?Utf-8?B?WWFtYQ==?=
Guest
Posts: n/a
 
      8th Apr 2005
800006000000 = string

"Jon Skeet [C# MVP]" wrote:

> Yama <(E-Mail Removed)> wrote:
> > I have the following binary data:
> >
> > 0x800006000000

>
> As what?
>
> > which is equivalent to the followin
> >
> > byte[] bytes = new byte[6];
> > bytes[0] = 0x80;
> > bytes[1] = 0x00;
> > bytes[2] = 0x06;
> > bytes[3] = 0x00;
> > bytes[4] = 0x00;
> > bytes[5] = 0x00;
> >
> > How can I parse the binary to the quivalent byte array?

>
> It would help if you could give more details. When you say you have the
> data, what format do you have it in? A long? A string?
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
>

 
Reply With Quote
 
Hung Huynh
Guest
Posts: n/a
 
      22nd Apr 2005
Yama wrote:
> Hi,
>
> I have the following binary data:
>
> 0x800006000000
>
> which is equivalent to the followin
>
> byte[] bytes = new byte[6];
> bytes[0] = 0x80;
> bytes[1] = 0x00;
> bytes[2] = 0x06;
> bytes[3] = 0x00;
> bytes[4] = 0x00;
> bytes[5] = 0x00;
>
> How can I parse the binary to the quivalent byte array?
>
> Thanks,
>
> Yama
>
>
>


String s = "800006000000";
long n = Int64.Parse(s);

byte[] a = new byte[8];
int s, i;
for (i = 0, s = 56; i < 8; i++, s -= 8)
a[i] = (byte)(0xFF & (n >> s));

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change binary data buffer read from a binary file to string format Anderson Microsoft VC .NET 1 21st Jul 2006 11:35 AM
Solver returns non binary answer in binary constrained cells =?Utf-8?B?TmF2eSBTdHVkZW50?= Microsoft Excel Worksheet Functions 6 1st Sep 2005 03:11 PM
Append binary file 2 to binary file 1? vbMark Microsoft C# .NET 8 22nd Aug 2005 09:09 PM
Binary operations (left/right shift, binary and/or, etc.) Mike Hodgson Microsoft Excel Programming 4 17th Jun 2005 09:27 AM
Convert binary file->utf8->binary file Joey Lee Microsoft C# .NET 2 25th Apr 2005 07:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:47 AM.