11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

56 Part I: Introduction to C++ ProgrammingRoman numeral expressionsOn a historical note, I should mention that somenumbering systems actually hinder computations.The Roman numeral system is a (so tospeak) classic example that greatly hinderedthe development of math.Adding two Roman numerals isn’t too difficult:XIX + XXVI = XLVThink this one out:a) IX + VI: The I after the V cancels out the Ibefore the X so the result is V carry the X.b) X + XX: Plus the carry X is XXXX, which isexpressed as XL.Subtraction is only slightly more difficult.Ah, but multiplying two Roman numerals all butrequires a bachelor’s degree in mathematics.(You end up with rules like X promotes the digitson the right by 1 letter so that X –* IV becomesXL.) Division practically required a Ph.D., andhigher operations such as integration wouldhave been completely impossible.Love those Arabic numerals . . .Performing Bitwise Logical OperationsAll C++ numbers can be expressed in binary form. Binary numbers use onlythe digits 1 and 0 to represent a value. The following Table 4-2 defines the setof operations that work on numbers one bit at a time, hence the term bitwiseoperators.Table 4-2OperatorFunctionBitwise Operators~ NOT: Toggle each bit from 1 to 0 and from 0 to 1&AND each bit of the left-hand argument with that on the right| OR each bit of the left-hand argument with that on the right^XOR (exclusive OR) each bit of the left-hand argument with that onthe rightBitwise operations can potentially store a lot of information in a small amountof memory. There are a lot of traits in the world that have only two (or, atmost, four) possibilities — that are either this way or that way. You are eithermarried or you’re not (you might be divorced but you are still not currently

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!