Tuesday, June 20, 2006

To Infinity But No Further!

So I'm taking a beginning programming class. The language is C++ and the most interesting thing I've learned so far is integer math. There are a few different kinds of numbers in C++ (and other languages), such as int (integers, plain numbers w/o decimals) and float (a number with decimals). The language handles operations on them differently. For example, when dividing two ints like five divided by two, the decimal is just dropped, so 5/2=2. If they were floats the answer would be 2.5.

My internal explanation for Why? was that different kinds of numbers were stored in different ways and have different limitations on them (because the limits of 32 bit computing seem always soon). So this morning I read this post linked from Digg and started to realize another handy reason why integer math exists: sometimes you don't want to spend your computer's time pondering the infinite.

No comments:

Post a Comment