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
1
vote
0 answers

Converting mono PCM to uLaw code to stereo

I have some c# code that has two functions. One converts linear PCM data to MuLaw format. The other function converts it back. public static Byte[] LinearToMulaw(Byte[] bytes, int bitsPerSample, int channels) public static Byte[]…
Tom
  • 527
  • 1
  • 8
  • 28
1
vote
1 answer

JavaScript simple BitConverter

I need to make simple C# BitConverter for JavaScript. I made simple BitConverter class BitConverter{ constructor(){} GetBytes(int){ var b = new Buffer(8) b[0] = int; b[1] = int >> 8 b[2] = int >> 16 b[3] = int >> 24 return…
Janso123
  • 192
  • 1
  • 12
1
vote
0 answers

Sending byte array through a Udp Socket and Bitconverter

I'm attempting to run a simple Udp Server and Client, but receiving incorrect data on the client side. On the server the byte array is constructed with this method: public byte[] CreateReplyPacket(byte[] data) { List
Astro Zero
  • 11
  • 5
1
vote
1 answer

Convert pointer to loop option in C#

How would I convert this into a loop and not to use the pointer. byte[] InputBuffer = new byte[8]; unsafe { fixed (byte* pInputBuffer = InputBuffer) { ((long*)pInputBuffer)[0] = value; } } I am trying to use the code from this…
Ridvan
  • 11
  • 3
1
vote
1 answer

Objective-C: How to read data from .NET's BitConverter class

In a .NET web application the BitConverter class is being used to convert Int32's into a byte array like so: byte[] intBuffer = BitConverter.GetBytes(12345); Now I am trying to read this back into an iPhone app. I have the bytes in an NSData with…
Jim
  • 75
  • 1
  • 1
  • 6
1
vote
1 answer

Converting from float (IEEE754) to byte[]

I'm using IEEE754 format to communicate some values via TCP. In this example, I'm converting an int to a byte[], and then using BitConverter to convert it to a float (already in IEEE754 Single format, 32-bits). I need to take this float and store it…
amorimph
  • 91
  • 2
  • 12
1
vote
1 answer

Converting Raw byte data to float[] and values needs to be between -1 and 1

I don't if I am doing it right, but I am using this method to convert a byte array to float array as shown in this link : public static float[] ConvertByteToFloat(byte[] array) { float[] floatArr = new float[array.Length / 4]; …
Mehdi Souregi
  • 3,153
  • 5
  • 36
  • 53
1
vote
1 answer

Convert integer to unsigned byte array with java or android

Hi i have seen many links in SO to convert integer value to unsigned byte array. but i can't able to get clear idea. my conversion is as follows //in android int checksum=104396; byte[] byteArray = GetBytesInt(checksum); public static byte[]…
user2634966
  • 179
  • 1
  • 16
1
vote
1 answer

c# switch on variable type

Is there a cuter way to do this? Given a byte stream to convert it to the desired number type. (Assume the calling code will be handling data types relevant to the number of bytes in the stream). public void GetValue(byte[] bytes, ref UInt16…
GarethD
  • 112
  • 1
  • 8
1
vote
2 answers

Bit convector : Get byte array from string

When I have a string like "0xd8 0xff 0xe0" I do Text.Split(' ').Select(part => byte.Parse(part, System.Globalization.NumberStyles.HexNumber)).ToArray(); But if I got string like "0xd8ffe0" I don't know what to do ? also I'm able for recommendations…
cnd
  • 32,616
  • 62
  • 183
  • 313
1
vote
1 answer

Overflow exception in C# for converting float number to decimal

I get an overflow exception when Convert.ToDecimal(float number here) is called. I'm reading from a byte string and hoping to convert the byte array to a decimal number. byte[] hexbyte = {45, 6, 7, 29}; float myFloat = BitConverter.ToSingle(hexbyte,…
MW_hk
  • 1,181
  • 4
  • 14
  • 39
1
vote
1 answer

Converting To Floating Point

I have two ushort integer. Integers : 2206,41247 I want to convert to float this integers. For this; void Main() { GetSingle(2206,41247).Dump(); } public static float GetSingle(ushort highOrderValue, ushort lowOrderValue) { return…
Stormcloak
  • 105
  • 2
  • 10
1
vote
0 answers

Convert bytes array to human readable string and vice versa in .NET

Since using Convert.ToBase64String & Convert.FromBase64String could lead to Out of Memory Exception, when very large string is input. Is there another alternative ways to convert a bytes array to human readable string and vice versa in .NET?
totorochan
  • 55
  • 1
  • 8
1
vote
3 answers

8 byte array back to long (C# to c++)

I'm converting a long to a 8 slot byte array with C# Byte[] Data = BitConverter.GetBytes(data.LongLength); For example if data.LongLenght is 172085, I get the following array { 53,160,2,0,0,0,0,0 } But then after I send this to my c++ server I would…
Nick3
  • 639
  • 1
  • 14
  • 40
1
vote
3 answers

Converting byte array to hexadecimal value using BitConverter class in c#?

I'm trying to convert a byte array into hexadecimal value using Bitconverter class. long hexValue = 0X780B13436587; byte[] byteArray = BitConverter.GetBytes ( hexValue ); string hexResult = BitConverter.ToString ( byteArray ); now if I execute the…
SanVEE
  • 2,009
  • 5
  • 34
  • 55