All software does, is present and manipulate information. Thus the first step to be a proficient programmer is to comprehend the structure and representation of information in the digital world. All information in a computer including files and programs is represented as a bunch of bits in memory, i.e. RAM, registers, hard disk, flash disk etc. Bit is a word coined from ‘binary digit’ a base two representation of numbers, which is done using zeros (0) and ones (1). Binary values are appropriate to save and process as information as the two values can be presented, stored, and transmitted easily and inexpensively, for instance, as a high or low voltage on a wire. Normally we use decimal numbers for our every day activities, this is a base ten representation of numbers which ranges from zero (0) to nine (9), moreover they are other representation most importantly the hexadecimal which is base sixteen. While Binary system is excellent for machine-level representation of information, presenting them (binary numbers) on screen or paper can be ambiguous as they can be really long. Here is where the Hexadecimal numbering system is used because of its close relationship to Binary. Converting from either and back is easy thus Hexadecimal it used as a kind of shorthand for binary.
Hex digit Decimal Value Binary Value 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111 8 8 1000 9 9 1001 A 10 1010 B 11 1011 C 12 1100 D 13 1101 E 14 1110 F 15 1111
Information in a computer is by standard represented in eight bit pairs. Eight bits form a byte, a word coined from ‘by eight’. A short study of the byte will take you a long way to understating the terms used in digital representation.
The first word is nibble, which means four bits or half a byte. This will be most important when converting between hexadecimal and binary. The second two words that you need to know describe bit position in a byte; most significant bit is the left most bit in a byte, and least significant bit is the right most bit in a byte. Word four and five give the state of a byte; signed bytes are stated as to be either positive or negative, but unsigned bytes do not have a state and so can only represent numbers from zero upwards. Before storage is done, some machines convert (reverse) the byte ordering so that the least significant bit comes first. This convention—the least significant bit coming first—is referred to as little endian. Most machines from Compaq and Intel are little endians. The opposite, where the most significant bit comes first is referred to as big endian. Most machines from IBM and Sun Microsystems are big endians.
Now you are ready to plug into the word of java primitive types.
In Java programming language a primitive type is predefined and named by a reserved keyword. We have eight primitive types with the following keywords —byte, short, int, long, char, float, double, and the boolean type. This can be grouped as byte, short, int, long, and char to represent the integral types. The float and the double represent the floating-point types and the boolean is just the boolean type. Integral types and floating-point types can be grouped together as numeric types.
The byte, short, int, and long, have values of 8-bit, 16-bit, 32-bit and 64-bit signed two's-complement (positive and negative) integers, respectively, and char, has values of 16-bit unsigned integers representing UTF-16 code units —UTF-16 is an encoding.
The float values include the 32-bit IEEE 754 floating-point numbers, and the double values include the 64-bit IEEE 754 floating-point numbers.
The boolean type has precisely two values: true and false.
No comments:
Post a Comment