Re: 8051 floating pt routines

From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 02/24/05


Date: Thu, 24 Feb 2005 03:09:43 GMT


"Nicholas O. Lindan" wrote:
>
... snip ...
>
> For interface to humans I convert float -> integer -> ASCII BCD
> for display. I scale the floating point value so it is between
> -9999, 9999 convert to BCD/ASCII and stick the decimal point
> where I need it. There isn't much physical that needs more than
> 4 digits to describe it.

Exactly. When I built my package for the 8080/z80 many moons ago I
used a three byte format, with 8 bits for exponent, and 16 for
significand with the implied leading 1 bit replaced by the sign.
This give 4.7 decimal digits of accuracy, and all the arithmetic
could be done in the registers. With care for proper rounding it
outperformed the available four byte packages in both speed (by a
factor of 5 to 10) and accuracy (over any extended calculations,
such as a three by three matrix reduction). The system included
i/o translation and formatting, and transcendental functions (trig,
log, exp).

The accuracy was always more than enough for the physical things it
was measuring and displaying.

For i/o I scaled to an integer in 6554..65535 and a power of ten,
with a separate sign. Again 3 bytes, because the power of ten byte
had room for a sign bit. The i/o worked with the resultant binary
significands, and BCD never entered the picture.

A slightly less polished version was published in DDJ. It got
faster and more compact later. IIRC it fitted into a single 2k
eprom. Doesn't meet the C standard requirements though.

-- 
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on 
 "show options" at the top of the article, then click on the 
 "Reply" at the bottom of the article headers." - Keith Thompson


Relevant Pages

  • Re: What wrong with XP?
    ... Remove check mark from "On resume, display welcome screen" ... Another way to do this is go to Start/Control Panel/Display/Screensaver on ... the bottom you will see Monitor power click on the Power. ...
    (microsoft.public.windowsxp.general)
  • Re: Explanation of my annoying bullish behaviour -
    ... freedoms, hundreds, and remedys are all bottom and mobile. ... We display them, then we as deal Tariq and Catherine's communist ...
    (sci.crypt)
  • Re: simple serial string display help
    ... I figured that my I/O thread would just constantly update an averaged ... display invalidation comes along, it just takes the averaged value. ... Paul G. Tobey wrote: ... , you might as well just do the I/O ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: System 7 audit mode help
    ... I have several known good Philips 5101 CMOS chips. ... that since the power supply had melted down I did some extensive work ... The issue now is I have the audit mode clearly showing on the bottom ... display. ...
    (rec.games.pinball)
  • Re: f-14 tech 2 questions
    ... Go for a Rottendog ... power supply and full display board. ... not tried to start a game to see what sound is like during game play. ...
    (rec.games.pinball)

Loading