Re: 8051 floating pt routines
From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 02/24/05
- Next message: CBFalconer: "Re: x86 architecture concepts"
- Previous message: Rich Webb: "Re: FPGA starting kit"
- In reply to: Nicholas O. Lindan: "Re: 8051 floating pt routines"
- Next in thread: Spehro Pefhany: "Re: 8051 floating pt routines"
- Reply: Spehro Pefhany: "Re: 8051 floating pt routines"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: CBFalconer: "Re: x86 architecture concepts"
- Previous message: Rich Webb: "Re: FPGA starting kit"
- In reply to: Nicholas O. Lindan: "Re: 8051 floating pt routines"
- Next in thread: Spehro Pefhany: "Re: 8051 floating pt routines"
- Reply: Spehro Pefhany: "Re: 8051 floating pt routines"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|