The use of floating point arithmetic has become common place in software. Developers do not even think about the consequences of using floating point.
Some years ago, the floating point unit (fpu) was optional when you purchased a computer. Individuals had the choice of using this chip or not. Computers today do not give you this choice. The manufacturers have imbedded the fpu into the cpu case so you are forced to purchase the fpu. It is generally assumed that all computers need a floating point unit. I am here to say that this is not true. If computers today need to have a floating point unit it is because a lot of software has been constructed to require the fpu. This is where the problem resides.
Software developers have taken for granted that every machine has an fpu, so why not use it? The problem with this line of thinking is that floating point operations are very time consuming. Even with floating point operations taking place in hardware, floating point is many times slower than integer arithmetic. Generally, software developers (of which I am one) use the following arguments for using floating point arithmetic:
As mentioned above, floating point operations (even hardware based) are many times slower than integer operations. Using floating point is an expensive way of performing calculations.
There is no fpu that is as fast as integer calculations. Floating point units tend to be 10's to 100's of times slower than integer calculations.
Many developers believe that certain types of math require floating point data types and operations. Typically, the following types of math are assumed to require floating point:
In reality, all of the above calculations do not really require floating point arithmetic. It is just that most software developers think in terms of floating point for so long, they cannot visualize these math operations done any other way.
Since the use of floating point is so widespread, many software libraries automatically use floating point data types without regard to real need. This causes a situation where software developers are using tools that make use of floating point perhaps without the developers' knowledge.
Most books that discuss mathematical calculations automatically assume that you will be using floating point arithmetic. Developers then use these algorithms in their own programs.
Since operating on floating point data types is many times slower than operating on integer data types, it makes sense not to use floating point or use floating point only when there is no other choice.
Even though floating point is regarded as required. It is over used and generally, not required. The mathematical calculations that, people suggest, require floating point arithmetic, in reality, do not require this. The reason I say that floating point is not really required goes back to a book called Starting Forth by Leo Brodie.
In this book, Mr. Brodie states that Forth programmers do not ever use floating point even when complex calculations (he uses the example of Fast Fourier Transforms, differential equations, non-linear least squares fitting and linear regression) are involved. Mr. Brodie maintains that complex math can be done using fixed point arithmetic instead of floating point.
It was in the mid-80's after reading Mr. Brodie's concept that I became anti-floating point. Although I do not generally get involved in intense mathematical programming, I can say with a clear conscience that I have never intentionally used floating point in any application.
Floating point is just too time consuming an expensive. The time, money and energy should be used to create a super-fast fixed point dedicated processor. This type of processor would be many hundreds (if not thousands) of times faster than any floating point processor. Any amount of precision and any number of digits can be used with fixed point arithmetic.
It is also my opinion that the over use of floating point data types is a contributing factor to bloated code.