Questions tagged [bitconverter]

Class in C# and Java that converts base data types to an array of bytes, and an array of bytes to base data types.

Class in C# and Java that converts base data types to an array of bytes, and an array of bytes to base data types.

138 questions
0
votes
1 answer

How do I limit BitConverter.GetBytes() to return only a certain amount of bytes using VB.NET?

I do: Dim BytArr() as Byte = BitConverter.GetBytes(1234) Since, by default, they are 32 bits, it returns 4 byte elements. I want to be able to control it to return only like two bytes. Maybe only three bytes. Are there any built-in functions to…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
0
votes
3 answers

Converting a big endian array to an Int64

Im using a System.IO.BinaryReader to read a data from a serialized file. The file is big endian. So what I did to read the Int64 (long) from the stream was read 8 bytes from it. What I need to do is convert those 8 bytes of big endian into little…
Cole Tobin
  • 9,206
  • 15
  • 49
  • 74
-1
votes
0 answers

a program gives me different results from debugging mode

in below code public partial class UC_Home : UserControl { static byte[] Data_From_Class_library { get; set; } string resultedStr { get; set; } public UC_Home() { InitializeComponent(); } public UC_Home(byte[]…
-1
votes
1 answer

Alternative to BitConverter that doesn't require fixed length, zero-padded byte arrays?

BitConverter.GetBytes always returns fixed length arrays for numbers, padded with zeros so that they are precisely 1, 2, 4, or 8 bytes long. Similarly, the decoding methods only accept arrays of certain lengths, depending on the size of the…
-1
votes
3 answers

Byte[] to float conversion

Float b = 0.995; Byte[] a = Bitconverter.GetBytes(b); Now my byte[] values are 82 184 126 63 .i.e., a[0] = 82, a[1] =184, a[2] = 126, and a[3] = 63. I want to revert back above byte to float.So,I used Bitconverter.Tosingle Float b =…
-1
votes
1 answer

Compress byte[] in c#

i have a method which Decompress byte array and i need opposite of this function(mean Compress).i googeled a lot but didnot find exactly opposit of this function public static byte[] Decompress(byte[] B) { MemoryStream ms = new…
ehsan
  • 29
  • 1
  • 6
-1
votes
5 answers

C# getting 1st 2 integers out of a byte array

I have a byte[] like this byte[] buffer = new byte[1024]; this byte[] may have values like this: buffer = {0, 0, 0, 106, 0, 0, 0, 11, 64, 33, 50, 32, 32, 32, ....} I am trying to get first 8 bytes, that is: 0,0,0,106 0,0,0,11 , and convert these…
cd491415
  • 823
  • 2
  • 14
  • 33
-1
votes
2 answers

equivalent of c# bitconverter in delphi

is there an equivalent of bitconverter.getbytes in Delphi? https://msdn.microsoft.com/en-us/library/fk3sts66(v=vs.110).aspx
lakdee
  • 57
  • 1
  • 8
-1
votes
2 answers

how to convert short to byte array in Objective-c?

In C# short can be converted to byteArray like this public void WriteShort(short value) { WriteBytes(flip(BitConverter.GetBytes(value))); } I want to implement this in C or Objective-C
yj chan
  • 13
  • 3
-2
votes
1 answer

Network Byte[] to Int64 problems

I am gathering binary information from a multicast stream on a VERY old system. I have converted most of it, but I am having problems with a High / Low DWORD Combo. I wrote a little test app to try to iron this out. I am being told the value…
vSteve
  • 63
  • 1
  • 1
  • 8
-2
votes
1 answer

C# Sockets byte array

Okay so i'm receiving bytes from a request.. I call to read the bytes byte[] buffer = new byte[1024]; int resp = socket.Receive(buffer); If I use this, Console.WriteLine(resp) it returns a integer of 9, meaning 9 bytes are…
Hostd
  • 25
  • 2
  • 8
-2
votes
2 answers

C# - are byte representations of different types different?

I know question is a bit weird, I'm asking out of pure curiosity, as I couldn't find any relevant info around. Also, please feel free to edit title, I know its terrible, but could not make up any better. Let say I have variable foo of type object,…
Pindwin
  • 77
  • 2
  • 7
-3
votes
1 answer

Bitcoin arbitrage collection formula

https://cryptorank.io/price/bitcoin/arbitrage I am working on displaying the various currencies like Bitcoin arbitrage URL shared above. There are number of the records with +9.53%, +7.7% against the other currencies. I tried hard to find out the…
vikas dhiman
  • 297
  • 3
  • 19
-3
votes
2 answers

Convert javascript string length to array of byte[]

I need to convert in javascript the length of a string to an array of bytes with length 2 (16-bit signed integer) equivalent to C# Bitconverter.GetBytes( short value). Example: 295 -> [1,39].
-3
votes
2 answers

Processing 1000's of parameters a second in C# by quickly converting data types from byte to other types

I have asked this question over the last 2 years and am still looking for a good way of doing this. What I am doing is as follows: I have a WPF/C# application which has been developed over the last 3 years. It takes a real time stream of bytes over…
Pantera
  • 11
  • 2
1 2 3
9
10