Score of 23
2 answers
1563 views
Why does C++26 add `CHAR_WIDTH` when we already have `CHAR_BIT`?
While reading cppreference, I noticed that C++26 adds a new macro named CHAR_WIDTH. For me it seems to have the same value as CHAR_BIT, which for me is 8. What's the difference between CHAR_BIT and ...
- reputation score 106119
Score of -1
1 answer
149 views
reading a "Long" out of bytes and changing endian order [closed]
I’m having an issue with reading a Long variable from a binary file in Java. My code: Static long extractLong (DataInputStream dis) throw IOException{ byte[] bytes = new byte[8]; dis.read(...
- reputation score 7
Score of 0
3 answers
109 views
Unescape string to get special character from user input
I have a user input as str in a CLI like using argparse: python -m service.run --separator \n When I collect the separator, I get the escaped version of the string "\\n", but instead I want ...
- reputation score 11792
Score of 11
3 answers
1111 views
Why does Java byte[] to int/int to byte[] need operation "&0xFF"
I am trying to convert from byte[4] to int, and int to byte[4]. But why does java need the operation of (bytes[0] & 0xFF) thing? Because, you know, in bit level, when you are doing &0xFF, the ...
- reputation score 125
Score of 0
1 answer
108 views
How to split byte array in C++
I am using C++ .NET. Here is example: cli::array<Byte>^ myBytes = bytes//the variable bytes //contains unpredictable amount of bytes, //it can be 32 or 128 or 256, no matter. And I have to ...
- reputation score 43
Score of 0
4 answers
67 views
How to write bytes as a b' string to a file?
from PIL import Image img = Image.open('some/file.png') img = img.convert(mode='1') imgbytes = img.tobytes() with open('filepath', 'w') as file_out: file_out.write(imgbytes) I would like to write the ...
- reputation score 1891
Score of 1
1 answer
163 views
Why can't I return type byte in lambda expression in Arrays.setAll
I'm trying to implement a lambda function (for educational purposes) to initiate an array to append to the front of potentially encrypted data to save information like salt and initiation vector, ...
- reputation score 127
Score of 0
2 answers
82 views
Calculate byte positions to split ndjson files into chunks
Below is the code extracted from this repo: import os.path, io filename = "" n_chunks = 12 # Number of processes to use -- will split the file up into this many pieces def ...
- reputation score 2880
Score of 0
1 answer
209 views
Split payload data from sensor into separate bytes length
Please I'm having an issue where I need to split a payload coming from an energy meter into chunks of 5-bytes each that represent different values of line parameters. The payload length is 35 bytes as ...
- reputation score 21
Score of 0
2 answers
252 views
How to reverse the bytes of a number in Excel?
In an excel cell, I have a large number represented as a string, lets say 12345689994765411. I am looking for a way to reverse the bytes inside that number to get the decimal representation of that ...
- reputation score 19198
Score of 0
1 answer
102 views
RabbitMQ received bytes are invalid
I've a rabbitMQ implementation (C# with RabbitMQ.Client 7.1.12 nuget) where we send a short json to a queue. But when the receiver gets the queue item sometimes (approximately 1 on 5) the byte array ...
- reputation score 2961
Score of 0
2 answers
154 views
How can i convert a negative binary number to sbyte(c#)
I am messing around with c#, and i noticed something. If i were to instantiate an sbyte with 8 bits, such as 0b_1111_1111 (-1), it throws an error, but if i were to first make a byte with it, and then ...
- reputation score 35