|MadSci Network: Computer Science|
To answer your question, we need to delve into the world of digital logic. All computing devices use collections of logic gates to implement airthmetic operations. For a good grounding in logic gates and their conceptual operation, please see: Summary of Logic Gates at Queen's University in Kingston, Ontario, Canada as well as Dr. Jeffrey J. Gosper's Simple Logic Gates page at Brunel University. There is also a simulator here that will allow you to see logic gates, and some of the basic assemblages of logic gates, at work. Physically, logic gates work by either allowing or inhibiting a voltage through the gate. For an overview on how TTL gates operate physically, see: Transistors and Digital Logic Gates, a web lecture from the Southern Polytechnic State University's Computer Science Department. As for "mixing" arithmetic operations, that can be construed on two levels: The digital logic level; and the algebraic level. For the digital logic level, most modern computing devices have a component referred to as an Arithmetic Logic Unit (ALU) which is a collection of the logic gates described on Dr. Gosper's site, and which serve just about any arithmetic function. This is known as combinational logic design. A very good resource for combinational logic can be found in Arithmetic Circuits. This site also describes the numbering systems used in Binary Coded Decimal (BCD) notation. Also, as you progress through the material at this site, you will see references to control lines and function inputs. These two concepts are the key to understanding how a multi-function array of logic gates operate. In the case of an ALU, the individual logic gates will have more than two inputs (sometimes many more). Included in these inputs will be a control line (or lines) which turns the gate "on". That control line receives its instructions (which gates to turn on for an arithmetic operation, and which to leave off) from an encoder. The encoder takes your input (i.e. you entered 2 + 3 on a keypad) and formats it for processing by the ALU. The encoder is where function inputs are formatted in order to tell the ALU which gates and values to use for the operation. At the algebraic level, computing devices observe the same order of precedence as a person would when performing calculations on paper; the primary difference is that a person may not always enforce the precedence correctly, whereas the computing device will. That order is, from left to right in an equation, multiplication, division, addition, and subtraction. With that in mind, it is also the person's responsibility to ensure that an equation entered in a computing device is written in the correct order. As for rounding, most computing devices do not begin to round until they exceed their units of precision. Rounding, in the digital logic sense, refers more to the closest number in a range of very small or very large numbers. To accomplish rounding, a Floating-Point Unit(FPU) is employed. The FPU may or may not be incorporated into an ALU. There is a freeware book online at Rutgers University entitled PRINCIPLES OF COMPUTER ARCHITECTURE by Miles Murdocca which covers almost every aspect of your question. I have only given the book a cursory inspection, but it seems to be quite complete and correct. You will need the Adobe Acrobat Reader to view the book, and it is available via a link on that page. For information on Floating Point logic, see Appendix A in the above referenced work. I hope this is sufficient to answer your question. If not, please feel free to contact me directly, or post a follow-up question on MAD Scientist. Thanks, Joe
Try the links in the MadSci Library for more information on Computer Science.