Eight Bit Byte Mac OS

Most likely, your input file uses a single-byte 8-bit encoding such as ISO-8859-1, frequently used to encode 'Western European' languages. Regardless of the actual market share, the most compatible version (across operating systems) of IE was 5.x, which had Mac OS 9 and Mac OS X, Unix, and most Windows versions available and supported for a short period in the late 1990s (although 4.x had a more unified codebase across versions). Assuming Snow Leopard (Mac OS X 10.6.2 - Intel), then 'long' is 64-bits with the default compiler. Specify 'g -m64' and it will likely be 64-bits on earlier versions too. How a particular host (processor, OS, etc.) handles the byte and bit order is off-topic here. In general, programming libraries handle the problem for your particular host, but that, too, is off-topic here, and you could try to ask about the programming aspect on Stack Overflow.

Table Of Content

1- Bit

I start the story by talking about base-10 system. When you understand the base-10 system, our story will not be interrupted and confused.
Okay, the base-10 system is the most popular one but it's not unique. Many cultures used different systems in the past, however, today most of them have moved to base-10 system. The base-10 system uses 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, which are put together to form another number.
If you only have one box, you can only write a number from 0 to 9. But ..
  • If you have two boxes, you can write a number from 0 to 99.
  • If you have three boxes, you can write a number from 0 to 999.
All boxes from right to left have a factor which is in turn 10^0, 10^1, 10^2, ...

BIT

BIT is short for Binary digIT (information unit). A bit that denotes value 0 or 1, is called the smallest unit in the computer. 0, 1 are two basic digits of base-2 system.
Let infer as base-10 system and apply it to base-2 system. If you have one box, you can write 2 numbers such as 0 and 1. If you have 2 boxes, you can write 4 numbers such as 00, 01, 10, and 11 (Note: Do not be mistaken, these numbers are ones of base-2 system).
For base-2 system, the boxes from right to left have 1 factor. They are in turn 2^0, 2^1, 2^2, ...
The following image describes the way how to convert a number of base-2 system to base-10 system.
Thus:
  • If you have two boxes in the base-2 system, you can write the largest number of 11 (base-2), which is equivalent to 3 in the base-10 system.
  • If you have 3 boxes in base-2 system, you can write the largest number of 111 (base-2), which is equivalent to 7 in base -10 system.
And you have the following table:
Box NumbersMaximum Number (Base-2)Convert to Base-10
111 (2^1 - 1)
2113 (2^2 - 1)
31117 (2^3 - 1)
4111115 (2^4 - 1)
51111131 (2^5 - 1)
611111163 (2^6 - 1)
71111111127 (2^7 - 1)
811111111255 (2^8 - 1)
9111111111511 (2^9 - 1)

Why does the computer use base-2 system but not base-10 system?

You surely ask the question 'Why does computer use base-2 system but not base-10 system?'. I have asked this question before, like you.
Computers operate by using millions of electronic switches (transistors), each of which is either on or off (similar to a light switch, but much smaller). The state of the switch (either on or off) can represent binary information, such as yes or no, true or false, 1 or 0. The basic unit of information in a computer is thus the binary digit (BIT). Although computers can represent an incredible variety of information, every representation must finally be reduced to on and off states of a transistor.
Thus, the answer is that computer does not have many states to store information, therefore, it stores information based on the two states of ON and OFF (1 and 0 respectively).
Your computer hard drive also stores data on the principle of 0, 1. It includes recorders and readers. It has one or more disks, which are coated with a magnetic layer of nickel. Magnetic particles can have south-north direction or north-south direction, which are two states of magnetic particle, and it corresponds to 0 and 1.
  • The reader of hard drive can realize the direction of each magnetic particle to convert it into 0 or 1 signals.
  • The data to be stored on hard drive is a line of 0 or 1 signals. The recorder of hard drive relies on this signal and changes the direction of each magnetic particle accordingly. This is the principle of data storage of hard drive.

2- Byte

Byte is an unit in computer which is equivalent to 8 bits. Thus, a byte can represent a number in range of0 to 255.

How Many Bytes In Bit

Why is 1 byte equal to 8 bit?

Your question is now 'Why is 1 byte equal to 8 bits but not 10 bits?'.
Eight Bit Byte Mac OS
At the beginning of computer age people have used baudot as a basic unit, which is equivalent to 5 bits, i.e. it can represent numbers from 0 to 31. If each number represents a character, 32 is enough to use for the uppercase letters such as A, B, ... Z, and a few more characters. It is not enough for all lowercase characters.
Immediately after, some computers use 6 bits to represent characters and can represent at maximum 64 characters. They are enough to use for A, B, .. Z, a, b.. Z, 0, 1, 2, .. 9 but not enough for other characters such as +,-,*, / and spaces.Thus, 6 bits quickly become to be restricted.
ASCII defined a 7-bit character set. That was 'good enough' for a lot of uses for a long time, and has formed the basis of most newer character sets as well (ISO 646, ISO 8859, Unicode, ISO 10646, etc.)
8-bit, a little bit more than 7-bit which is better. It doesn't cause too large waste. The 8-bit is a collection of numbers between 0 and 255 and it satisfies computer designers. The concept of byte was born, 1 byte = 8 bits.
For 8-bit, Designers can define other characters, including special characters in computer. ANSI code table was born which is inheritance of the ASCII code table:
There are many character sets with a view to encoding characters in different languages. For example, Chinese, Japanese require a lot of characters, in which case people uses 2 bytes or 4 bytes to define a character.

Table Of Content

1- Overview of data types

Any programming language has a set of data types. Data types are basic, and quite similar for all languages. All data types are composed from bits, therefore, I dedicate a post to introduce the history of bits and bytes. My advice is that you should read it before continuing reading this post.
Java has two types of data types:
  • Primitive Types
  • Reference Types
There are 8 primitive data types which are boolean, byte, char, short, int, long, float, double.
Data typeDefault ValueSize
booleanfalse1 bit
char'u0000'2 byte
byte01 byte
short02 byte
int04 byte
long0L8 byte
float0.0f4 byte
double0.0d8 byte
  • Logic type: boolean.
  • Integer types: byte, short, char, int, long.
  • Real number type is also called floating point: float, double.
Reference types, which are objects created by the constructor of classes.

2- byte

1 byte a byte is composed of 8 consecutive bits in the memory of computer. Each bit is a binary number of 0 or 1. Java uses 'byte' to name a integer type with small scope (Size: 1 byte).
The first bit in a row of 8 bits has value of 0 or 1.
  • If it is 0, Java considers it as + (Represent a positive number)
  • If it is 1 Java considers it as - (Represent a negative number)
For next 7 bits, you can represent a number between 0 and 127. From here you deduce the byte type in Java with the range of [-127, 127].
But wait, it is supposed to be [-128, 127], why?

Why is the smallest number of byte type in Java -128?

If the rules that the first bit has a value of 0 equivalent to +, the value of 1 equivalent to -, then we have two ways to represent 0 (see the illustration).
Therefore, the binary sequence of '1 0 0 0 0 0 0' should be considered as the smallest number of byte data type in Java. It represents -128.

3- boolean

boolean is the simplest data type. It has size of 1 bit. It has 2 values of true and false.

4- char

Eight Bit Byte Mac Os X

Although 'char' is the first four characters of the 'Character' term, the char type in Java is used to store non-negative integers with the two-byte size. It is also used to represent for a Unicode character because in nature, each character corresponds to a specific number. (This number is understood as the code of character.)
Because char is non-negative integer type, size: 2 bytes, its scope is [0, 2*16-1] ( [0, 65535] ).
When char is understood as a Unicode character, the smallest character is 'u0000' (Mã 0), and the largest character is 'uffff' (code: 65535).
  • TODO

5- short

short is data type for the purpose of representing a two-byte integer (16 bits), including negative integer.
  • The smallest value is -32,768 (-2^15) and the largest value is 32,767 (2^15 -1).
  • Default value is 0.
** Note: See the explanation of the rule to determine the positive or negative number in the section of byte data type.

6- int

int data type is used to represent an integer with the size of 4 bytes (32 bits).
  • The smallest value: -2,147,483,648 (-2^31)
  • The largest value: 2,147,483,647 (2^31 -1)
  • Default value: 0.
In Java, the int data type is considered as default data type for integers. Therefore, if you write 100, Java will create a four- byte memory area for storage. And if you want Java to create an eight- byte memory area to store 100, you have to write 100L. (long is an eight-byte integer type, introduced in the following section).

7- long

The long data type is used to represent integers with the size of 8 bytes (64 bits).
  • The smallest value is -9,223,372,036,854,775,808.(-2^63)
  • The largest value is 9,223,372,036,854,775,807. (2^63 -1)
  • This type is used when a value pattern wider than int is necessary.
  • Default value is 0L.

8- float

float data type is used to represent a real number with the size of 4 bytes (32 bits).
  • The smallest value: -3.4028235 x 10^38
  • The largest value:: 3.4028235 x 10^38
  • Default value: 0.0f

9- double

double data type is used to represent a real number with the size of 8 bytes (64 bits). It is the default type for real numbers.
  • The smallest value: -1.7976931348623157 x 10^308
  • The largest value: 1.7976931348623157 x 10^308
  • Default value: 0.0d

10- Reference Types

In Java, a data type created by a combination of primitive types is called a reference type. The most commonly used reference type is the String, which is a combination of characters.
Reference types are created based on a class. The class is like a blueprint to define a reference type.