Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting from int to Byte[4]?
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00942999
Message ID:
00943007
Views:
21
Well I guess it wasn't that hard. Here is the code (could use some cleaning up)
System.Int64 iInt = 2864434397; // equal to AABBCCDD in hexadecimal
System.Byte[] bByte = new System.Byte[4];

bByte[0] = Convert.ToByte(iInt/(256*256*256));
if (iInt/(256*256) <= 255)
{
  bByte[1] = Convert.ToByte(iInt/(256*256));
}
else
{
  bByte[1] = Convert.ToByte((iInt/(256*256))%256);
}
if (iInt/(256) <= 255)
{
  bByte[2] = Convert.ToByte(iInt/256);
}
else
{
  bByte[2] = Convert.ToByte((iInt/256)%256);
}
bByte[3] = Convert.ToByte(iInt%256);
Now this looks like a lot of work to simply convert, any comments are welcome.

Thanks,
Einar
Semper ubi sub ubi.
Previous
Reply
Map
View

Click here to load this message in the networking platform