Hypothetical question,
Could you take that <$1 calculator chip and make it control an autonomous aircraft using GPS to navigate?
Probably not, but I wouldn't place any bets against somebody doing it.
The problem is that the modern day calculator is the result of 40 years of evolution in silicon. The chips that are now considered "Simple" calculators, contain millions of transitors, doing fairly complex functions that can't be simulated with a few lines of code.
Granted, floating point math CAN be done in software, but it comes at a heafty price. The "price" being, Program Space. If you don't mind sacrificing that space, you can always include the Free - Floating Point routines found here ... http://www.melabs.com/resources/fp.htm
Once you use those files, you'll see how much code it takes. And to just include all that stuff on a general basis, or because 1 formula in a program used a decimal point, would not only waste space needlessly, but would tend to Tick people off a bit... Make that, a Large Bit.
Quite often, the chip in use may only have 1 or 2K words of program space. I wouldn't want F.P. using 800 words, and leaving me the rest.
Plus, while Floating Point works great if you're calculating the distance to the Moon in meters (or inches), it doesn't do sqwat for the robot 5.2 feet from a wall. In fact, it will probably induce errors that need not happen. Not to mention waisting a whole bunch of time in the process.
I think the final blow for me was when I subtracted 7 from 8 and got 0.9999999
But, this is not the End of the World. Just a plee for a different line of thought.
Usually, a request for Floating Point Math stems from the thought that "I need to use Decimals, ie 24.21"...
Ennnhhhhhhh! ... Wrong Answer!
With only a few additional statements, you can work with Decimals just as easy as integers. BUT, you'll need to keep track of the decimal point youself. (worth it)
So what is 24.21? Well, one way to look at it is 2,421 hundredths of 1 unit. And since it's in Hundredths, it's easy to display. Divide by 100.
Value = 2421
LCDOUT DEC Value / 100,".", dec2 Value // 100
; output = 24.21
Wala. Decimals without F.P.
Well, OK, it's a bit trickier than that. But it's a start.
...
Alright, I went 2 paragraphs beyond this point when I realized how bad I was rambling, so I'll stop here. But hey, I got more. (ramblings)
I'd just rather Ramble in the direction that intrests you. So, why do you need F.P.?
<br>
Bookmarks