music 
OSdata.com 
binary numbers
summary
Binary numbers are the natural internal representation for digital computers.
free computer programming text book projecttable of contents

music 
OSdata.com 
Binary numbers are the natural internal representation for digital computers.
free computer programming text book projecttable of contents

This subchapter is a stub section. It will be filled in with instructional material later. For now it serves the purpose of a place holder for the order of instruction.
Professors are invited to give feedback on both the proposed contents and the propsed order of this text book. Send commentary to Milo, PO Box 1361, Tustin, California, 92781, USA.
Binary numbers are the natural internal representation for most digital computers. For the first few decades there were some computers that were primarily decimal and many processors still include some binary coded decimal (BCD) operations.
Most modern computers have two different internal sizes for binary integers, a standard int and a long. Many also have a short binary integer, which is typically a single byte long.
Most modern computers allow for both signed and unsigned integers. Signed integers include zero, positive integers, and negative integers. Unsigned integers include only zero and positive integers (excluding negative integers). Unsigned integers allow for approximately double the number of integers and are commonly used for addressing hardware memory (as well as for software pointers).
Most programming languages tie their integer choices to these underlying hardware characteristics.
All numeric data in C is stored as binary numbers.
Default and maximum precision can vary by implementation.
Fixed Binary declarations:
type of data: coded arithmetic (binary)
S/360, S/370 data format: fixed point
default precision: 16 bits
maximum precision: 31 bits
example:
DECLARE LOCAL_DISTANCE FIXED BINARY (31,16) INIT (256.5);
First number in declaration is the total number of stored bits. Second number in declaration (optional) is the number of bits to the right of an implied “decimal” point. If the second number is zero or left out, then the number is an integer.
Generally the fastest execution time for arithmetic. Sizes 16 bits or fewer are stored in two bytes. Sizes 1731 bits are stored in four bytes.
Undeclared variables starting with the letters I through N, inclusive, default to FIXED BINARY (15).
Many decimal fractions have no exact binary equivalent, which may result in a small rounding error.
Binary is a number system using only ones and zeros (or two states).
Decimal is a number system based on ten digits (including zero).
Hexadecimal is a number system based on sixteen digits (including zero).
Octal is a number system based on eight digits (including zero).
Duodecimal is a number system based on twelve digits (including zero).
binary  octal  decimal  duodecimal  hexadecimal 

0  0  0  0  0 
1  1  1  1  1 
10  2  2  2  2 
11  3  3  3  3 
100  4  4  4  4 
101  5  5  5  5 
110  6  6  6  6 
111  7  7  7  7 
1000  10  8  8  8 
1001  11  9  9  9 
1010  12  10  A  A 
1011  13  11  B  B 
1100  14  12  10  C 
1101  15  13  11  D 
1110  16  14  12  E 
1111  17  15  13  F 
10000  20  16  14  10 
10001  21  17  15  11 
10010  22  18  16  12 
10011  23  19  17  13 
10100  24  20  18  14 
10101  25  21  19  15 
10110  26  22  1A  16 
10111  27  23  1B  17 
11000  30  24  20  18 
Signmagnitude is the simplest method for representing signed binary numbers. One bit (by universal convention, the highest order or leftmost bit) is the sign bit, indicating positive or negative, and the remaining bits are the absolute value of the binary integer. Signmagnitude is simple for representing binary numbers, but has the drawbacks of two different zeros and much more complicates (and therefore, slower) hardware for performing addition, subtraction, and any binary integer operations other than complement (which only requires a sign bit change).
In one’s complement representation, positive numbers are represented in the “normal” manner (same as unsigned integers with a zero sign bit), while negative numbers are represented by complementing all of the bits of the absolute value of the number. Numbers are negated by complementing all bits. Addition of two integers is peformed by treating the numbers as unsigned integers (ignoring sign bit), with a carry out of the leftmost bit position being added to the least significant bit (technically, the carry bit is always added to the least significant bit, but when it is zero, the add has no effect). The ripple effect of adding the carry bit can almost double the time to do an addition. And there are still two zeros, a positive zero (all zero bits) and a negative zero (all one bits).
In two’s complement representation, positive numbers are represented in the “normal” manner (same as unsigned integers with a zero sign bit), while negative numbers are represented by complementing all of the bits of the absolute value of the number and adding one. Negation of a negative number in two’s complement representation is accomplished by complementing all of the bits and adding one. Addition is performed by adding the two numbers as unsigned integers and ignoring the carry. Two’s complement has the further advantage that there is only one zero (all zero bits). Two’s complement representation does result in one more negative number (all one bits) than positive numbers.
Two’s complement is used in just about every binary computer ever made. Most processors have one more negative number than positive numbers. Some processors use the “extra” neagtive number (all one bits) as a special indicator, depicting invalid results, not a number (NaN), or other special codes.
In unsigned representation, only positive numbers are represented. Instead of the high order bit being interpretted as the sign of the integer, the high order bit is part of the number. An unsigned number has one power of two greater range than a signed number (any representation) of the same number of bits.
bit pattern  signmag.  one’s comp.  two’s comp  unsigned 
000  0  0  0  0 
001  1  1  1  1 
010  2  2  2  2 
011  3  3  3  3 
100  0  3  4  4 
101  1  2  3  5 
110  2  1  2  6 
111  3  0  1  7 
See also Data Representation in Assembly Language
Coding example: I am making heavily documented and explained open source code for a method to play music for free — almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a frontend to YouTube (which checks the copyright permissions for you).
View music player in action: www.musicinpublic.com/.
Create your own copy from the original source code/ (presented for learning programming).
return to table of contents
free downloadable college text book
Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.
previous page  next page 
Tweets by @osdata 
free computer programming text book projectBuilding a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming. If you like the idea of this project, Supporting the entire project: If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church) free downloadable college text book on computer programming. 
This web site handcrafted on Macintosh computers using Tom Bender’s TexEdit Plus and served using FreeBSD .
†UNIX used as a generic term unless specifically used as a trademark (such as in the phrase “UNIX certified”). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.
Names and logos of various OSs are trademarks of their respective owners.
Copyright © 2010, 2011 Milo
Created: October 31, 2010
Last Updated: September 13, 2011
return to table of contents
free downloadable college text book
previous page  next page 