Questions tagged [byte]

A unit of information usually corresponding to 8 bits. This term is also most often used to indicate the smallest addressable unit of storage on a digital system.

A unit of information usually corresponding to 8 bits. This term is also most often used to indicate the smallest addressable unit of storage on a digital system.

These days, the term byte usually refers to a unit of information consisting of 8 . Historically, other sizes have been used as well. If one wants to stress the fixed size, the term octet can be used instead.

7742 questions
2
votes
1 answer

Is Minecraft missing zlib uncompressed size in it's chunk/region data?

Info on minecraft's region files Minecraft's region files are stored in 3 sections, the first two giving information about where the chunks are stored, and information about the chunks themselves. In the final section, chunks are given as a 4-byte…
zandgall
  • 23
  • 4
2
votes
2 answers

Equivalent Perl pack ("H*") in Java with non-hexadecimal characters

I'm trying to rewrite Perl script to Java. There is a line in this script with pack function: my $key = '0rdR-0PrdK'; $key = pack("H*", $key); The method i use in java is: private static byte[] hexToBytes(String s) { int len = s.length(); …
2
votes
2 answers

Are there any performance differences between representing a number using a (4 byte) `int` and a 4 element unsigned char array?

Assuming an int in C++ is represented by 4 bytes, and an unsigned char is represented by 1 byte, you could represent an int with an array of unsigned char with 4 elements right? My question is, are there any performance downsides to representing a…
nreh
  • 476
  • 8
  • 13
2
votes
1 answer

How to take bytes as input without any manipulation in it in python?

I am taking a byte as input b'\xe2I4\xdd\r\xe5\xfcy^4\xd5' but it gets converted into string. so when i am to trying to convert this string to byte it is again manipulating it and giving me output as: b"b'\\xe2I4\\xdd\\r\\xe5\\xfcy^4\\xd5'" My…
user13505457
2
votes
1 answer

Why does bytes data change during conversion between bytes and strings?

I've found a phenomenon I can't really understand in Java and I post a question Put some data into the byte array Convert byte array to string Convert the converted string back to a byte array When comparing the first data and the data after…
2
votes
3 answers

How do you transfer single byte into word in C for Cortex?

Without resorting to typedef union, is there working macro for Cortex-M0 in C where it copy byte data into word within 31 to 23. I have recieved data from spi and need to copy this data into word. The SRAM does not work with bit manipulation, so I…
Riscy
  • 843
  • 4
  • 13
  • 28
2
votes
3 answers

How do you save multitype/form data to a hard file in Python with FastAPI UploadFile?

https://fastapi.tiangolo.com/tutorial/request-files/ *Solved Below * I've gotten an appropriately sized array of bytes and I'm not sure how to parse it correctly to save received form file data. Almost working: @app.post("/uploadfiles/") async def…
2
votes
2 answers

Write hexadecimal values into register with leading zeros

I have an string array which contains 16 hexadecimal values. I need to convert them into byte to write them at Modbus's device register(size of each register is 16-bit). We have 8 registers to write 16 hexadecimal values. So, I'm converting them…
2
votes
1 answer

One byte converting to two when written to file

I do not understand why my code is not working. I am writing some very simple code to write a single byte to a file. with open("foo.txt", "w+", encoding='utf-8') as f: f.write('\x80') As you can see below, it ends up writing two bytes when I…
Professor Dragon
  • 217
  • 1
  • 4
  • 14
2
votes
0 answers

Python Serial - how to decode to string

I'm using the python serial module to try to read a rotary encoder. I am receiving something but I am not sure what it is? When not turning the encoder I get the following bytes: b'y\xf6\xf6\xf6\xf6\x16\xd6\x16\xb6\xd6\x06\x00' When I turn the…
Mike C.
  • 1,761
  • 2
  • 22
  • 46
2
votes
1 answer

Converting packed ascii to ascii and back

I'm developing an application to communicate with a serialport device. The device itself is developed according to HART protocol. Some documentation that I found related to this: Packed ASCII is a subset of full ASCII and uses only 64 of the 256…
user5583043
2
votes
0 answers

Define a bytes object with the size of 1

I want to have a bytes object with the size of 1. I tried the built-in declaration: >>> bytes(3) b'\x00\x00\x00' However, even though set the parameter equal to zero, the size of this exact object is not zero because of its internal structure. >>>…
Memphis Meng
  • 1,267
  • 2
  • 13
  • 34
2
votes
2 answers

How to convert a text file having a hexadecimal code sequence into a byte array?

So I was wondering if there any possibility to read a plain text bytes sequence in hexadecimal from a text file? The Bytes Are Saved On to A Text File in Text Format e.g. : string text = @"0x4D, 0x5A, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04,…
Harsh Raj
  • 33
  • 4
2
votes
1 answer

Common Lisp struggle with read-byte/write-byte

I want to be able to write bytes and read them from standard input/output but when I try this in SBCL I get the error "The stream has no suitable method[...]", why is this and how would I go about to make my own stream which can handle bytes?
Johan
  • 605
  • 5
  • 16
2
votes
1 answer

python how to convert bytes to binary

I'm trying to read a file's contents and convert them into what is actually stored in memory if I write file = open("filename","br") binary = "0b" for i in file.read(): binary += bin(i)[2:] will binary equal the actual value stored in…
forever
  • 207
  • 2
  • 8
1 2 3
99
100