Don't take adding for granted.
Posted on 25.08.2009 09:57 am
As programmers we take things for granted. It's almost our job. It's what helps us develop larger and larger things. And after a while, we forget how we implemented that cool functionality and then we become users of our code.
This can become dangerous, since a user of the code is prone to using it in a way it was not meant to be used.
Programmers are curious people, and that's what keeps us at the top of our game. And I think all programmers should have a healthy obsession over how everything works. Even the most basic of things.
A great example is addition and subtraction. Something we use every day and never think about.
Here are a few adding machines (taken from the wikipedia article above)
A mechanical adder might represent two addends as the positions of sliding blocks, in which case they can be added with an averaging lever. If the addends are the rotation speeds of two shafts, they can be added with a differential.
A hydraulic adder can add the pressures in two chambers by exploiting Newton's second law to balance forces on an assembly of pistons.
The most common situation for a general-purpose analog computer is to add two voltages (referenced to ground); this can be accomplished roughly with a resistor network, but a better design exploits an operational amplifier.
In modern digital computers, integer addition is typically the fastest arithmetic instruction, yet it has the largest impact on performance, since it underlies all the floating-point operations as well as such basic tasks as address generation during memory access and fetching instructions during branching.
There are a lot of very cool implementations out there, from simple fun things like the binary marble adding machine up to Clock of the Long Now
- Instead, the clock uses binary digital logic, implemented mechanically in a sequence of stacked binary adders (or as their inventor, Hillis, calls them, serial bit-adders). In effect, the conversion logic is a simple digital computer (more specifically, a digital differential analyser), implemented with mechanical wheels and levers instead of typical electronics. The computer uses a 28-bit number representation, with each bit represented by a mechanical lever or pin that can be in one of two positions. This binary logic can only keep track of elapsed time, like a stopwatch; to convert from elapsed to local solar time (that is, time of day), a cam subtracts from (or adds to) the cam slider, which the adders move.
0 5 Like it or hate it? - Comment (0)
Process time: 0.009894 seconds