Questions tagged [byte]
The byte tag has no usage guidance.
27 questions
2
votes
5
answers
1k
views
The size of a byte in platform independent software
When writing platform independent software in C++, can I nowadays safely1 assume that a byte has a size of 8 bits? Or do I have to calculate it like this, for example:
#include <climits>
std::...
-2
votes
1
answer
2k
views
Generate large Excel files and response from API
I need to generate a large Excel file (something around 50 megs) and send response to another API which will provide it to the front end for a download option.
My question is if it will be better to ...
0
votes
1
answer
1k
views
Java takes 2 bytes to represent character?
In general a character is represented in 1 byte i.e. 8 bits . This is I believe true for all text editors even for databases like oracle. 1 byte
can represent 2^8 = 256 Characters.
My question is when ...
5
votes
5
answers
2k
views
How can the same sequence of bytes might represent an integer, floating-point number, character string, or machine instruction?
I have just started to study about computer systems and I came across this line. How can the difference in the contexts in which we view data objects make this happen?
Bytes store numbers, now that ...
7
votes
3
answers
674
views
What is the procedure(if any) to select bytes to represent opcodes?
TL;DR
What procedure is followed when selecting bytes to represent opcodes? Are byte(s) for opcodes just randomly chosen, and them mapped to mnemonics?
I recently learned from this answer that ...
4
votes
3
answers
3k
views
How exactly is bytecode "parsed"?
How is Bytecode "parsed"?
It is my understand that Bytecode is a binary, intermediate representation of the syntax of a given programming language. Certain programming languages convert their source ...
12
votes
6
answers
1k
views
Is power-of-two bits per word "convenient"? If it is, why is that?
I find several sources claiming that power-of-two bits in a binary word (such as 8-bits per byte) is a "good thing" or "convenient". I find no source pointing out why.
From What is the history of ...
3
votes
5
answers
804
views
Why isn't byte | bit the only built in data type?
All languages I have seen so far have multiple builtin data types (int, double, float, char, long...).
But if we look closely, they are just arbitrary arrays of bits, the only difference between them ...
4
votes
4
answers
7k
views
Byte addressable vs bit addressable
Why are most computers byte addressable instead of bit addressable?
By B/b addressable I mean that processor can operate on level of single B/b.
Bit addressable advantages:
Booleans have size of ...
5
votes
1
answer
13k
views
What is the difference between size and length? [closed]
It seems that the terms size and length are used interchangeably to describe how many bits, bytes or octets some data occupies, i.e. a length field in a data header is said to indicate the size of the ...
0
votes
2
answers
588
views
read file bytewise and find information
i am a hobby php-dev and have the following problem:
i have a rar-file, whose header is damaged, therefor extracting is not fully possible. the contents are non-compressed, and can be read with eg. a ...
4
votes
2
answers
2k
views
Endianness at bit level
I am learning the union and struct and I wrote the code below. What I do not understand is why the output is different when I change from a little endian to a big endian machine.
My understanding is ...
1
vote
1
answer
1k
views
C# Structs, 16 byte rec. - Are getters and setters included in that?
I was reading into the nitty-gritty of structs in C# here: "C Fundamentals, The differences between struct and class."
and at the very bottom it mentions keeping a struct below 16 bytes. I ...
6
votes
3
answers
2k
views
Is a 'least significant bit' used anywhere practically today?
I'm working on a library that supports file reading, and right now I've always assumed that all the bytes are written in most significant bit first format. Is the least significant bit first format ...
2
votes
1
answer
31k
views
Whats the difference between byte and Byte? [duplicate]
Alright so of course, I know the differences.
byte is a primitive and Byte is an object. Byte offers more functions but there is one thing I dont understand. Why would anyone create a variable using ...
7
votes
1
answer
13k
views
Benefits of Java ByteArrayInputStream vs byte array?
I have a scenario where my Java process will be receiving a stream of binary data:
public class DataHandler {
public void handleData(DATA data) {
// TODO: Do something with data
}
}
...
0
votes
2
answers
489
views
Does ASCII have a header or footer or anything similar?
I'm working through a problem in Programming Pearls -- specifically, the implementation of a program which sorts a file containing, at most, 10,000,000 integers, each of which is 7 digits long (Column ...
12
votes
4
answers
3k
views
Is there any danger in writing raw bytes to a file? [closed]
I'm working through a problem in Programming Pearls -- specifically, the implementation of a program which sorts a file containing, at most, 10,000,000 integers (Column 1, Problem 3). Since the book ...
36
votes
11
answers
16k
views
Why do we still use floats? [duplicate]
I understand why floats served a purpose in the past. And I think I can see why they're useful in some simulation examples today. But I think those example are more exceptional than common. So I ...
3
votes
3
answers
2k
views
8 bit and 1 byte, is this a valid question to be asked?
I saw these question in our school's past paper, and I'm wondering if this is a valid question.
How big is bool in C and C++?
A) 1 bit
B) 4 bit
C) 8 bit
D) 1 byte
What is ...
2
votes
4
answers
14k
views
How to get from 1 byte to 2 bytes
We have 1 byte, which is 8 bits, which is 2^8. Now 2 bytes should be 2 * 1 byte, which is 2 * 2^8 = 2^9, but actually 2 bytes is 2^16. What am I missing here? It seems like 2 bytes isn't 2 * 1 byte, ...
1
vote
3
answers
426
views
How do I tell a user that bps means bits per second or bytes per second?
I'm writing an application that deals with the network and the hard drive. For the network portion, the application measures in bits per second, while the disk portion measures in bytes per second. ...
12
votes
5
answers
29k
views
How do you compress ASCII strings into fewer bytes?
I'm working with an embedded device with a unique protocol that sends messages to other devices and I'm making an application that parses the sent packets. Each packet carries 8 bytes. The protocol is ...
7
votes
5
answers
122k
views
How many bits' address is required for a computer with n bytes of memory?
How many bits of address is required (for the program counter for example) in a byte-addressed computer with 512 Mbyte RAM?
What does the formula look like?
How is this connected with the fact that ...
3
votes
1
answer
3k
views
Java default Integer value is int
My code looks like this
import java.util.Scanner;
public class StudentGrades {
public static void main(String[] argv)
{
Scanner keyboard = new Scanner(System.in);
byte q1 = keyboard....
42
votes
12
answers
6k
views
Is there an alternative to bits?
Is there an alternative to bits as the smallest unit of data? Something that won't be only 0 or 1, but actually hold many possible states in between? Wouldn't it be more natural to store floats like ...
102
votes
7
answers
83k
views
What is the history of why bytes are eight bits?
What were the historical forces at work, the tradeoffs to make, in deciding to use groups of eight bits as the fundamental unit?
There were machines, once upon a time, using other word sizes. But ...