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

C# signed fixed point to floating point conversion

I have a temperature sensor returning 2 bytes. The temperature is defined as follows : What is the best way in C# to convert these 2 byte to a float ? My sollution is the following, but I don't like the power of 2 and the for loop : static void…
0
votes
1 answer

c# 1D-byte array to 2D-double array

I'm dealing with c# concurrent-queue and multi-threading in socket-programming tcp/ip First, I've already done with socket-programming itself. That means, I've already finished coding about client, server and stuffs about communication itself basic…
0
votes
1 answer

Equivalent of BitConverter.ToUInt16 of C# for Java 7

My question is about Java. I need a method that returns an unsigned 16-bit integer converted from two bytes at the specified position in a byte array. In other words I need the equivalent of the method BitConverter.ToUInt16 of C# for Java that works…
0
votes
1 answer

Equivalent of BitConverter.ToUInt16 of C# for Java

My question is about Java What is the equivalent of BitConverter.ToUInt16 for Java? I am trying to translate this method of C#: public static implicit operator ushort(HashlinkReader p) { ushort tmp =…
0
votes
2 answers

How to convert bytes to an int using bit converter in c#

I have a code that returns array of bytes which could be one byte or more or less. The problem relies in that when I convert the bytes some times I get an error because I can't determine when I need to use toInt32, toInt64, or toInt16. The other…
moe1792
  • 29
  • 6
0
votes
1 answer

BitConvert.IsLittleEndianon on different endian architectures

The documentation of BitConverter.IsLittleEndian says: Indicates the byte order ("endianness") in which data is stored in this computer architecture. "this" is confusing me. Say I have the following…
Marlon
  • 19,924
  • 12
  • 70
  • 101
0
votes
2 answers

Convert byte array to objects C++ | C# Bitconverter in C++

I have a C++ server that receives a byte array from a client written in C# (I'm using SFML UDP sockets). In the client, I encode the packet information using System.Bitconverter. How would I go about extracting the information from the packet on…
volairs22
  • 83
  • 6
0
votes
1 answer

TCP / Async Receive Handle for more then 500 clients

I am a complete beginner in the TCP section, I try to program a Master Server which should handle more then 500 clients with small delay. This is my first attempt, do you have any suggestions how to improve the code, or is my code complete garbage!…
Kenion
  • 105
  • 1
  • 10
0
votes
0 answers

C# BitConverter Single Conversion Error

I have a requirement to be able to parse a special NaN byte array to determine a specific condition. The array is 0x0000A07F. However, when I run this through BitConverter and cast to a float and then back to a byte array, the conversion does not…
BJD
  • 1
  • 1
0
votes
2 answers

C# BitConverter to Java

I am trying to port some existing C# code that uses BitConverter to Java. I have found various other threads, but then happened upon a github class that appears to do the trick. However, the ToUInt16 does not match the output from my C# code. The…
scarpacci
  • 8,957
  • 16
  • 79
  • 144
0
votes
2 answers

BitConverter.ToInt16 Adds 0xFFFF to Number? (C#)

I've got a problem here that's probably something that I'm just overlooking, but I can't understand why it's happening... The problem I'm having is that I'm using the bit converter to give me an Int16 from a 2-byte array, but for some reason…
Lander
  • 3,369
  • 2
  • 37
  • 53
0
votes
1 answer

BitConverter.ToInt64 OverflowException

I had error "OverflowException" at first step (i=0). What is wrong in this code? Dim byteArray As Byte() = { _ 0, 54, 101, 196, 255, 255, 255, 255, 0, 0, _ 0, 0, 0, 0, 0, 0, 128, 0, 202, 154, _ 59, 0, 0, 0, 0, 1,…
Güven Acar
  • 95
  • 1
  • 10
0
votes
1 answer

Calculate checksum return wrong value in android

Hi am converting c# application to android and am calculating checksum from byte array as same as in c#. But it return wrong value below byte array. Anyone please help on this.Thank you. C# byte array: [41, 132, 41, 132, 41, 132, 41, 132, 41, 132,…
Nas
  • 2,158
  • 1
  • 21
  • 38
0
votes
1 answer

help with BitConverter!

I cannot get the BitConverter class to work. I get the error 'BitConverter' undeclared (first use this function). I have tried putting 'using System;' at the top of my code because I saw that in some examples online, but it then tells me that…
Seth Nelson
  • 143
  • 1
  • 1
  • 6
0
votes
1 answer

c# improve binary serialization

I am currently working on a project that generates code based on other code. Essentially using the programming language itself as a DSL. One of the generator targets is a binary DataContract serializer and the generated ToBytes for the following…
Toxantron
  • 2,218
  • 12
  • 23