+--First Church of Briantology--Order of the Holy Quaternion--+
| A mathematician is a device for turning coffee into         |
| theorems.              -Paul Erdos                          |
+-------------------------------------------------------------+
|                       Jake Wildstrom                        |
+-------------------------------------------------------------+
> For a retrocomputing project I'm doing, I'd really like to know how
> the Apple II (in particular Applesoft Basic) handled floating point --
> I'm going to be using software FP, and I'm trying to make it mimic
> Apple II behavior as much as possible. Any pointers to
> algorithms/specifications would be muchly appreciated.
I'm aware of three relatively common floating point implementations on
the Apple II:
- Applesoft BASIC
- Apple II Pascal
- Standard Apple Numerics Library (SANE)
Applesoft's implementation came from Microsoft.  It uses five bytes to
store the floating point number, with a similar range of magnitudes to
IEEE-754 single precision floating point (i.e. 7 bit exponent), but with
a larger mantissa hence greater precision.  I don't have time to check
right now, but there is probably more information available in the
reference manuals.  An interesting point about the Applesoft floating
point engine is that it had some well known bugs which you may want to
emulate.
I don't know what Apple II Pascal used.  It is probably documented in
the manual, which is rather deeply buried at the moment.  I think it had
four bytes for floating point variables, so it is probably similar to
IEEE-754 single precision.
SANE _is_ IEEE-754/854, using single, double and extended precision (4,
8 and 10 bytes respectively).  The SANE library was available for 8-bit
Apple II models (used by AppleWorks, for example), and is part of the
toolbox for the Apple IIgs and Macintosh.
Please see:
http://til.info.apple.com/tilarchive.nsf/artnum/n74
http://til.info.apple.com/tilarchive.nsf/artnum/n75
http://www.6502.org/source/source.htm
Paul R. Santa-Maria
Monroe, Michigan USA
Paul, I have tried to use the source files you have posted but they are in a
difficult format to use.  It would be much more handy if you were to
assemble them and post the listing file instead.  Creating new source from
the listing file is much simpler than trying to create them from the
original tokenized source file.
> Jake Wildstrom <wil...@mit.edu> wrote:
> 
> > For a retrocomputing project I'm doing, I'd really like to know how
> > the Apple II (in particular Applesoft Basic) handled floating point --
> > I'm going to be using software FP, and I'm trying to make it mimic
> > Apple II behavior as much as possible. Any pointers to
> > algorithms/specifications would be muchly appreciated.
> 
> I'm aware of three relatively common floating point implementations on
> the Apple II:
> 
> - Applesoft BASIC
> - Apple II Pascal
> - Standard Apple Numerics Library (SANE)
> 
> Applesoft's implementation came from Microsoft.  It uses five bytes to
> store the floating point number, with a similar range of magnitudes to
> IEEE-754 single precision floating point (i.e. 7 bit exponent), but with
> a larger mantissa hence greater precision.  I don't have time to check
> right now, but there is probably more information available in the
> reference manuals.  An interesting point about the Applesoft floating
> point engine is that it had some well known bugs which you may want to
> emulate.
Somewhere I have an article describing the bugs.
> 
> I don't know what Apple II Pascal used.  It is probably documented in
> the manual, which is rather deeply buried at the moment.  I think it had
> four bytes for floating point variables, so it is probably similar to
> IEEE-754 single precision.
It was similar, but not identical. I recall it had an 8 bit exponent
(excess 128?) and 23 bit normalised mantissa. The SANE package had
conversion routines to/from for it. If you hunt around my Sydney Uni web
page (assuming it's still there) for my MATHPACK.TEXT unit, some
functions using trix records show how the Pascal floating point could be
used and manipulated.
> 
> SANE _is_ IEEE-754/854, using single, double and extended precision (4,
> 8 and 10 bytes respectively).  The SANE library was available for 8-bit
> Apple II models (used by AppleWorks, for example), and is part of the
> toolbox for the Apple IIgs and Macintosh.
I have the complete 8 bit version for Pascal, Prodos and Apple 3
somewhere, assuming the disks still work...
Adrian.
--
Dr A.P. Whichello                               Phone: +61 2 6201 2431
Electronics & Telecommunications Engineering  Fax: +61 2 6201 5041
University of Canberra             Email: adr...@ise.canberra.edu.au
Australia                      WWW: http://www.ee.usyd.edu.au/~adrianw
"I wish to God these calculations had been executed by Steam!" C.Babbage
-- 
*(C)ontinue  (A)bort  (F)all Asleep*
thanks,
Ralf
Not exactly a "chip", since the Apple II didn't have any FPP socket.
There was a *card* using the MC68881 that was supported by ORCA/C.
I don't understand how to make it work.  APPLESOFT.sit contains individual
tokenized S-C assembler source files, not a DSK image.  FID appears to only
work with DSK images, not individual files.  What am I doing wrong?