answersLogoWhite

0


Best Answer

A byte is the smallest unit of addressable storage. Although a bit is smaller than a byte, a single bit cannot be addressed directly; we always deal with groups of bits and a byte is the smallest group of bits that can be physically addressed. However, once we have addressed a byte, we can then examine the individual bits within it using the bitwise logic operators (AND, OR, NOT and XOR).

On most systems a byte is exactly 8 bits in length. The reason for this is simply that we can represent any 8-bit value using a convenient two-digit hexadecimal notation, where each hex digit represents exactly 4-bits (often called a nybble because it is half-a-byte). Thus an 8-bit byte can be represented by any hexadecimal value in the range 0x00 to 0xff (or 0 to 255 decimal).

(Some systems use odd-size bytes, such as a 9-bit byte. For this we typically use 3-digit octal notation because an octal digit represents exactly 3 bits. Such systems are rare, but we sometimes come across other odd-sized bytes, especially in older data transfer systems such as dot-matrix printers which utilised a 7-bit byte. However, in modern architecture, we can safely say that a byte is always at least 8 bits long.)

Not all programming languages utilise a byte data type as such. C, for instance, doesn't have a built in byte data type but it does have a char data type which is always 1 byte in length. There's no real reason why there isn't a byte data type in C, but when all data types are measured in terms of bytes it was probably deemed unnecessary to say that a byte is 1 byte in length. Although a char is typically used to encode a single character from a character set (and has built in overloads specific to that purpose), the encoding is no less numeric than a byte would be, so there was no real need for a separate byte data type.

Although a single byte can represent any decimal value in the range 0 to 255, it is more correct to say that a single byte can represent any one of 256 unique abstractions. Whether it is a single character from a character set, an unsigned value in the range 0 to 256, or a signed value in the range -128 to +127, these are merely abstractions. How abstractions are interpreted is entirely down to the programmer and/or the programming language.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the benefits of byte as a datatype?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the size for long datatype in .net?

Long variables are stored as signed 64-bit (8-byte) integers ranging in value from -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807.


What is the best datatype for storing your birthday?

in Unix: the datatype is "Date" in C++: the datatype is "char"


What is the best datatype for storing birthdays?

in Unix: the datatype is "Date" in C++: the datatype is "char"


Write a program that show size of datatype?

sizeof(datatype)


Can you assign a char value to a variable of datatype of byte in java?

Not without casting. A char is a 16 bit type, whereas a byte is an 8 bit type. Therefore the compiler cannot guarantee that the 16 bit value will fit into the 8 bit value without overflowing. If you attempt to stick a char into a byte, you will get a compiler error. To override this, you can cast the char value to a byte during assignment. However, you might get some unexpected results. A few examples below: char a = 'A'; byte b = a; //compiler error char a = 'A'; byte b = (byte)a; //valid, no error. b=65 char a = 172; byte b = (byte)a; //valid, no error, but b=-84 because of overflow.


What is the datatype of a class?

While there are obvious data types like primitives (boolean, char, byte, short, int, long, float, double) and arrays, really any class which stores some form of information can be considered a data type. Objects like String, BigInteger, and the whole Collections framework also belong in this category.


What is mean by parse in java?

It is used to convert the value of one datatype into a value of another datatype. Example- Integer.parseInt(in.readLine); It converts given value to Integer datatype.


What is datatype of pointers?

pointer


C program to implement tower of hanoi using array implementation of stack abstract datatype?

stack abstract datatype


How do you declare functions?

datatype function_name() { }


What datatype is weapon name?

double


What is user define datatype and explain it?

Any datatype which the user creates in code, that isn't native to the language. A linked list can be an example of this