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
2 answers

How to form 32 bit integer by using four custom bytes?

I want to create a 32 bit integer programmatically from four bytes in hex such as: Lowest byte is AA Middle byte is BB Other middle byte is CC Highest byte is DD I want to use the variable names for that where: byte myByte_1 = 0xAA byte myByte_2 =…
GNZ
  • 575
  • 2
  • 10
2
votes
2 answers

Python - convert signed int to bytes

this code works fine: an_int = 5 a_bytes_big = an_int.to_bytes(2, 'big') print(a_bytes_big) but when i change an_int to -5, i get the following error: a_bytes_big = an_int.to_bytes(2, 'big') OverflowError: can't convert negative int to…
2
votes
1 answer

How do I save bytes as an image?

I was trying to save bytes as an image, but it doesn't seem to be working. here is what I tried: from PIL import Image from io import BytesIO image = open('D:\pythonScreenshots\screenshot1.jpg', 'rb') a = image.read() stream = BytesIO(a) image =…
natitati
  • 35
  • 4
2
votes
1 answer

What does the 'flush' argument of File.writeAsBytes do in Dart.io?

In the dart.io documentation for File.writeAsBytes It says of the flush argument: If the argument flush is set to true, the data written will be flushed to the file system before the returned future completes. But I don't know what "flushed to the…
Nerdy Bunz
  • 6,040
  • 10
  • 41
  • 100
2
votes
2 answers

Add To Bytes without overflow

For some API Integration, I have an operation where I need to add two bytes and get a single byte as a result. It's some kind of a checksum. Now by nature there can happen overflows. For example byte a = 0xff byte b = 0x01 byte results = a + b; Is…
Boas Enkler
  • 12,264
  • 16
  • 69
  • 143
2
votes
2 answers

How to unpack bytes in "pairwise reversed" order BA DC?

I have a binary string where the bytes are reversed in the following way: The file contains e.g the four bytes 0x18 0xb1 0x35 0x41 and should be interpreted as 0xb1 0x18 0x41 0x35 into my perl string or array. That is, every pair of bytes is…
Anna
  • 2,645
  • 5
  • 25
  • 34
2
votes
1 answer

Why are the byte representations for extended ASCII characters from bytes() different from chr()?

(I am working in python) Suppose I have this list of integers a = [170, 140, 139, 180, 225, 200] and I want to find the raw byte representation of the ASCII character each integer is mapped to. Since these are all greater than 127, they fall in the…
nullb12
  • 21
  • 3
2
votes
2 answers

Insert data into Oracle table Using Python script. Expected str instance, bytes found

I want to insert data into Oracle Table, where one row type-RAW(In python BYTES). sql = f"INSERT /*+ APPEND */ INTO {table} ({columns}) VALUES ({values})" ins_r = ', '.join(lst) cur.execute(sql, ins_r) This is my printed SQL: INFO - INSERT /*+…
LOTR
  • 113
  • 1
  • 1
  • 10
2
votes
2 answers

How to turn a PCM byte array into little-endian and mono?

I'm trying to feed audio from an online communication app into the Vosk speech recognition API. The audio comes in form of a byte array and with this audio format PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, big-endian. In order to be able…
moeux
  • 191
  • 15
2
votes
1 answer

Efficiency of factor vs. characters - object size

I come across something odd. I always thought storing data as factor variable if possible and if meaningful will result in a better storage efficiency. But when I look at this: object.size(c( "A", "B", "B", "0", "A", "AB", "0")) # 720 Bytes gr <-…
Nadiine El Nino
  • 339
  • 1
  • 6
2
votes
3 answers

C# Problem using blowfish NET: How to convert from Uint32[] to byte[]

In C#,I'm using Blowfish.NET 2.1.3's BlowfishECB.cs file(can be found here) In C++,It's unknown,but it is similiar. In C++,the Initialize(blowfish) procedure is the following: void cBlowFish::Initialize(BYTE key[], int keybytes) In C#,the…
Ivan Prodanov
  • 34,634
  • 78
  • 176
  • 248
2
votes
1 answer

How to calculate byte length of one UTF8 character using Excel VBA?

I need to cater a case that handles the byte length of some UTF8 characters (some are Chinese and some are Japanese). So far as I know, one UTF8 character can occupy spaces range from 1 byte to 4 bytes. I need to count the bytes used by one…
StanleyLMW
  • 23
  • 3
2
votes
2 answers

c++ syntax error when declaring an array of bytes

Im trying to declare an array of bytes so I can go through them and use each one of them seperatly. This is the array const BYTE keybyte[] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, …
Ethan Shulman
  • 43
  • 1
  • 4
2
votes
5 answers

C#: Cannot convert from ulong to byte

Strange how I can do it in C++,but not in C#. To make it clear,i'll paste the two functions in C++ and then in C# and mark the problematic lines in the C# code with a comment "//error". What the two function does is encoding the parameter and then…
Ivan Prodanov
  • 34,634
  • 78
  • 176
  • 248
2
votes
0 answers

Convert String to Byte String in Javascript

In Python, I have the following code to store bytes in a variable like: - K = b"\x00" * 32 I was trying to write a javascript equivalent of this code to get bytes string using the following code: function toUTF8Array(str) { var utf8 = []; for…
Suman Saha
  • 101
  • 1
  • 3