FLOATING POINT FOR TDS2020F
DESCRIPTION
TDSFLOATANS is a fully featured floating point handling package
for the TDS2020F single board computer. It contains all of the American National
Standard Forth floatingpoint and floatingpoint extension words, plus many
other useful functions.
The software is supplied in source code. Apart from normal calculator operations,
a full range of trigonometrical, logarithm, exponential and hyperbolic functions
is included with 8 to 10 digits accuracy. The code is not reentrant so floating
point words should only be used in one task of a multitasking system.
It is available as a passwordprotected file ansfp.zip file in the ‘downloads’
section of www.TriangleDigital.com or on the Triangle Digital Support CD. Purchase
of a licence for this software allows you to use the compiled code in an unlimited
way, but not to divulge the source code to any person or corporate body.
.
FLOATING POINT FAST START GUIDE
TO INPUT NUMBERS
FLOATON enables the
Forth interpreter to accept numbers in scientific format (it should be in the
word executed at powerup in a final system ROM). This is how floating point
literals should be entered  for example to store and print 16bit, 32bit and
floating point representations of the number ten:
: TEST1 (  ) 10 . 10. D. 1.0E1 F. ;
On execution the word TEST1
prints:
10 10 10.000000
Strings can be converted to floating point numbers with >FLOAT . Note that as well as the resulting
floating point number, it also leaves a flag to indicate whether the conversion
was successful. For instance:
: TEST2 (  ) S" 1234.5678" >FLOAT DROP F. ;
A third (non ANS Forth) way is provided in this package for
applications which need to get a number from the operator of the machine you're
designing. The word FINPUT" gets
a floating point number from the user. He can type it with or without a decimal
point, or even in scientific notation, and the result will be correct. For example:
: TEST3 (  r )
INPUT"
Input a number: " ." The number is " F. ;
This is what may happen when executed. Note that if a mistake
is made the number is rerequested:
TEST
Input a
number: 123.456 The number is 123.45600
Input a
number: 13 The number is 13.000000
Input a
number: 13k.9
Input a
number: 13.9 The number is 13.900000
TO OUTPUT NUMBERS
We already saw that F. prints
the floating point number on the top of the stack. For instance 1.23456789E3 F. will print 1234.5679 when executed, also illustrating
the rounding to 8 significant digits. Eight is just the default, you can choose
any number up to ten. The last two places may not correct, it depends on the
arithmetic you are performing. Set the number of digits as follows:
5 SETPRECISION 1234.5678E0 F.
This will display 1234.6
(note the correct rounding) and only 5 digits will be used until SETPRECISION is used again.
Both scientific and engineering formatting are also supported:
: TEST4 (  ) 1.2345678E2 FDUP F. FDUP FE. FS. ;
When executed this will illustrate the three formats:
123.45678 123.45678E0
1.2345678E2
All output is via EMIT so
you can revector it as usual to display floating point numbers on an LCD for
example.
TYPE CONVERSION
You can also input integers as 16bit or 32bit numbers, followed
by a conversion to the floating point type. For example:
1234 S>F 12345678. D>F
In a definition you get faster execution by doing the conversion
in the execute rather than compile mode:
[ 1234 S>F ]
FLITERAL [ 12345678. D>F ] FLITERAL
In the reverse direction any fractional part is discarded. Eg:
: TEST5 (  )
1234567.8E0
F>D D. 1234.5678E0 F>S . ;
TEST5 will display 1234567 1234
.
ARITHMETIC & STACK MANIPULATION
This is straightforward but you may need to remember that each
floating point number in this package is represented by three 16bit entries
on the stack. This means that FOVER is
the same as a hypothetical word 3OVER .
TRIGONOMETRY
You are not restricted to 90 degrees, or even to a full circle.
All angles work but you must specify them in radians, not degrees. This package
has the non ANS Forth words DEG>RAD and
RAD>DEG to do the conversion. For instance:
30 S>F DEG>RAD
FSIN F.
will display 0.50000000 which
is the sine of 30 degrees.
SUMMARIES BY FUNCTION
STACK & ADDRESS MANIPULATION
F!

( r aa  )

Store r at address aa

F@

( aa  r )

Fetch r from address aa

FALIGN

(  )

Align dataspace pointer

FALIGNED

( ca  aa )

aa is aligned address >= ca

FCONSTANT

( r "<spaces>name"  )

Define floating point constant


name Execution:  r )

Place r on stack

FDEPTH

(  +n )

+n is possible floatingpoint values on stack

FDROP

( r  )

Remove r from stack

FDUP

( r  r r )

Duplicate r

FINT

( r1  r2 )

Round r1 to integer (towards 0)

FLITERAL

Compilation: ( r  )

Compile r


Runtime: (  r )

Place r on stack

FLOAT+

( aa1  aa2 )

Add size of floatingpoint number (6) to aa1

FLOATS

( n1  n2 )

n2 is size of n1 floatingpoint numbers

FOVER

( r1 r2  r1 r2 r1 )

Place a copy of r1 on top of the stack

FROT

( r1 r2 r3  r2 r3 r1 )

Rotate top three floatingpoint entries

FSWAP

( r1 r2  r2 r1 )

Exchange top two floatingpoint items

FVARIABLE

( "<spaces>name"  )

Create a definition for name, reserve three bytes of
data space (which is not initialised)


( name Execution:  aa )

aa is address of the reserved space

ARITHMETIC
F*

( r1 r2  r3 )

Multiply r1 by r2

F+

( r1 r2  r3 )

Add r1 to r2

F

( r1 r2  r3 )

Subtract r1 from r2

F/

( r1 r2  r3 )

Divide r1 by r2

F0<

( r  flag )

True if r less than zero

F0=

( r  flag )

True if r equal to zero

F2*

( r1  r2 )

Fast floating point multiply by 2

F2/

( r1  r2 )

Fast floating point divide by 2

F<

( r1 r2  flag )

True if r1 less than r2

FABS

( r1  r2 )

r2 is absolute value of r1

F=

( r1 r2  flag )

True if r1 is equal to r2

F>

( r1 r2  flag )

True if r1 greater than r2

FLOOR

( r1  r2 )

Round r1 to integer (towards minus infinity)

FMAX

( r1 r2  r3 )

r3 is greater of r1 and r2

FMIN

( r1 r2  r3 )

r3 is lesser of r1 and r2

FNEGATE

( r1  r2 )

r2 is negation of r1

FROUND

( r1  r2 )

Round r1 to nearest integer

FSQRT

( r1  r2 )

r2 is square root of r1

F~

( r1 r2 r3  flag )

True if the difference between r1 & r2 is less than
r3

TRIGONOMETRY
DEG>RAD

( r1  r2 )

r2 is r1 degrees converted to radians

FACOS

( r1  r2 )

r2 is radian angle whose cosine is r1

FASIN

( r1  r2 )

r2 is radian angle whose sine is r1

FATAN

( r1  r2 )

r2 angle whose tangent is r1

FATAN2

( r1 r2  r3 )

r3 is radian angle whose tangent is r1/r2

FCOS

( r1  r2 )

r2 is cosine of the radian angle r1

FSIN

( r1  r2 )

r2 is sine of the radian angle r1

FSINCOS

( r1  r2 r3 )

r2 is the sine and r3 the cos of r1

FTAN

( r1  r2 )

r2 is tangent of the radian angle r1

PI PI/2 PI/4

(  r )

Useful floating point constants

RAD>DEG

( r1  r2 )

r2 is r1 radians converted to degrees

HYPERBOLIC FUNCTIONS
FACOSH

( r1  r2 )

r2 is value whose hyperbolic cosine is r1

FASINH

( r1  r2 )

r2 is value whose hyperbolic sine is r1

FATANH

( r1  r2 )

r2 is value whose hyperbolic tan is r1

FCOSH

( r1  r2 )

r2 is hyperbolic cosine of r1

FSINH

( r1  r2 )

r2 is hyperbolic sine of r1

FTANH

( r1  r2 )

r2 is hyperbolic tangent of r1

EXPONENTIALS & POWERS
FALOG

( r1  r2 )

Raise ten to the power r1

FEXP

( r1  r2 )

Raise e to the power r1

FEXPM1

( r1  r2 )

Raise e to the power r1 and subtract one

F**

( r1 r2  r3 )

Raise r1 to the power r2

LOGARITHMS
FLN

( r1  r2 )

r2 is natural logarithm of r1

FLNP1

( r1  r2 )

r2 is natural logarithm of r1, plus one

FLOG

( r1  r2 )

r2 is baseten logarithm of r1

INPUT FUNCTIONS
>FLOAT

( ca u  r true  false )

Convert string to floatingpoint

D>F

( d  r )

Convert 32bit double d to floatingpoint

FINPUT"

(  r )

Request a floating point input

FLOATOFF

(  )

Disable floating point input

FLOATON

(  )

Enable floating point input

S>F

( n  r )

Convert 16bit single n to floatingpoint

OUTPUT FUNCTIONS
F>S

( r  n )

n is the integer portion of r

F.

( r  )

Display top floating point number on stack

F>D

( r  d )

Floatingpoint integer part to double

FE.

( r  )

Display top floating point number on stack using engineering
notation

FS.

( r  )

Display top number on stack in scientific notation

PRECISION

(  u )

No. of digits used by
F. , FE. , or FS.

REPRESENT

( r ca u  n flag1 flag2 )

Convert mantissa of r to an ASCII string represented
as a decimal fraction (with implied decimal point to the left of first
digit), and exponent as n, the sign as flag1 and "valid result" as flag2

SETPRECISION

( u  )

Set number digits used by F. , FE. , or
FS.

IEEE FLOATING POINT REPRESENTATION
DF!

( r aa  )

Store r as 64bit IEEE doubleprecision



number at aa

DF@

( aa  r )

Fetch 64bit IEEE doubleprecision number stored at aa

DFALIGN

(  )

Align dataspace pointer

DFALIGNED

( ca  aa )

aa is aligned address >= ca

DFLOAT+

( aa1  aa2 )

Add size of 64bit IEEE doubleprecision number (8) to
aa1

DFLOATS

( n1  n2 )

n2 is size of n1 64bit IEEE double



precision numbers

SF!

( r aa  )

Store r as a 32bit IEEE singleprecision number at aa

SF@

( aa  r )

Fetch 32bit IEEE singleprecision number stored at aa
to stack

SFALIGN

(  )

Align dataspace pointer

SFALIGNED

( ca  aa )

aa is aligned address >= ca

SFLOAT+

( aa1  aa2 )

Add size of a 32bit IEEE singleprecision

SFLOATS

( n1  n2 )

n2 is size of n1 32bit IEEE singleprecision numbers

NUMBER REPRESENTATION
Floating point numbers consist of three 16bit cells and are
arranged on the stack as follows, the range is ±7.0 x 109863.
exp (exponent)

: s : msb : lsb :

m1 (mantissa top word)

: s : msb : 3sb :

m2 (mantissa bottom word)

: 2sb : lsb :

where msb = 'most significant byte' and 's' = sign etc. Floating
point numbers are 'normalised', ie: for positive numbers bit 14 of m1 is 1.
SYSTEM DOCUMENTATION
ANS FORTH SYSTEM
TDS2020FLOATANS: providing the FloatingPoint word
set. Providing the FloatingPoint Extensions word set.
IMPLEMENTATION DEFINED OPTIONS
Format and range of floatingpoint numbers: see above.
Results of REPRESENT
when float is out of range: does not occur.
Rounding or truncation of floatingpoint numbers: F* F+ & F
round to nearest but midway numbers are rounded up.
F/ truncates.
Size of floatingpoint stack: shares data stack, 118
bytes allowing 39 floating numbers.
Width of floatingpoint stack: 3 cells, 48 bits.
AMBIGUOUS CONDITIONS
DF@ or DF! is used with an address that is not doublefloat
aligned: ADDR ERR exception.
F@ or F! is used with an address that is not float
aligned: ADDR ERR exception.
Floating point result out of range ( F/ ): undefined result.
SF@ or SF! is used with an address that is not singlefloat
aligned: ADDR ERR exception.
BASE is
not decimal ( REPRESENT F. FE. FS. ) : output is not
affected by BASE .
Both arguments equal zero (
FATAN2 ) : FP INV ARG exception.
Cosine of argument is zero as an argument for FTAN : FP DIV 0 exception.
d can't be precisely represented as float in D>F : does not occur.
Dividing by zero ( F/
) : FP DIV 0 exception.
Exponent too big for conversion (
DF! DF@ SF! SF@ ) : FP RANGE exception.
Float less than one (
FACOSH ) : FP INV ARG exception
Float less than or equal to minus one ( FLNP1 ) : FP INV ARG exception.
Float less than or equal to zero (
FLN FLOG ) : FP INV ARG exception.
Float less than zero (
FASINH FSQRT ) : FP INV ARG exception.
Float magnitude greater than one (
FACOS FASIN FATANH ) : FP INV ARG exception.
Integer part of float can't be represented by d in F>D : FP INV ARG exception.
String larger than pictured numeric output area ( F. FE. FS. ) : does not occur with FE. or FS.
because of the limit on PRECISION . F. uses scientific format in place of very
long fixedpoint strings but this is for convenience only and the threshold
length, FXLIMIT , can be independent
of the size of the pictured numeric output area.
TDS2020F ANS FORTH
FLOATING POINT WORD DEFINITIONS
STACK EFFECT ABBREVIATIONS
Symbol

Data type

+n

nonnegative 16bit singlecell number

aa

aligned address

ca

characteraligned address

d

32bit signed doublecell number (two's complement)

false

false flag (0)

flag

boolean flag. 0 = false, nonzero = true. flag = 1 when
true flag left by a word

n

16bit signed singlecell number

true

true flag (1)

u

16bit unsigned singlecell number

r

real (floating point) number (6 bytes, 3 words, 48 bits)

ALPHANUMERIC WORD DEFINITIONS
>FLOAT
ANS
ca u  r true  false
An attempt is made to convert the string specified by ca and
u to internal floatingpoint representation. If the string represents a valid
floatingpoint number in the syntax below, its value r and true are returned.
If the string does not represent a valid floatingpoint number only false is
returned. A string of blanks is treated as a special case representing zero.
The syntax of a convertible string is:
<significand>[<exponent>]
where:
<significand>
:= [<sign>]
<digits>[.<digits0>]  .<digits>
<exponent>
:= <marker><digits0>
<marker>
:= <eform>  <signform>
<eform>
:= <echar>[<signform>]
<signform>
:= +  
<echar>:= D  d  E  e
>FLOAT enables programs
to read floatingpoint data in legible ASCII format. Embedded spaces are explicitly
forbidden, as are other field separators such as comma or slash. Example string:
1.234e8
D>F ANS
d  r
r is the floatingpoint equivalent of 32bit integer d.
DEG>RAD
r1  r2
r2 is r1 degrees converted to radians.
DF! ANS
r aa 
Store the floatingpoint number r as a 64bit IEEE doubleprecision
number at aa. If the significand of the internal representation of r has more
precision than the IEEE doubleprecision format, it will be rounded using the
"round to nearest" rule.
DF@
ANS
aa  r
Fetch the 64bit IEEE doubleprecision number stored at aa to
the floatingpoint stack as r in the internal representation. If the IEEE doubleprecision
significand has more precision than the internal representation it will be rounded
to the internal representation using the "round to nearest" rule.
DFALIGN
ANS

If the dataspace pointer is not doublefloat aligned, reserve
enough data space to make it so.
DFALIGNED ANS
ca  aa
aa is the first doublefloataligned address greater than or
equal to ca..
DFLOAT+
ANS
aa1  aa2
Add the size in address units of a 64bit IEEE doubleprecision
number to aa1, giving aa2.
DFLOATS
ANS
n1  n2
n2 is the size in address units of n1 64bit IEEE doubleprecision
numbers.
F! ANS
r aa 
Store r at aa.
F* ANS
r1 r2  r3
Multiply r1 by r2 giving r3.
F** ANS
r1 r2  r3
Raise r1 to the power r2, giving the product r3.
F+ ANS
r1 r2  r3
Add r1 to r2 giving the sum r3.
F ANS
r1 r2  r3
Subtract r1 from r2, giving r3.
F. ANS
r 
Display, with a trailing space, the top number on the floatingpoint
stack using fixedpoint notation:
[]<digits>.<digits0>
For example, 1.23E3 F.
displays 1230
F/ ANS
r1 r2  r3
Divide r1 by r2, giving the quotient r3.
F0< ANS
r  flag
flag is true if and only if r is less than zero.
F0= ANS
r  flag
flag is true if and only if r is equal to zero.
F0>
r  flag
flag is true if r is greater than 0.
F2*
r1  r2
Fast floating point multiply by 2.
F2/
r1  r2
Fast floating point divide by 2.
F< ANS
r1 r2  flag
flag is true if r1 is less than r2.
F=
r1 r2  flag
flag is true if r1 is equal to r2.
F>
r1 r2  flag
flag is true if r1 is greater than r2.
F>D ANS
r  d
d is the 32bit signedinteger equivalent of the integer portion
of r. The fractional portion of r is discarded.
F>S
r  n
n is the 16bit signedinteger equivalent of the integer portion
of r. The fractional portion of r is discarded.
F@ ANS
aa  r
r is the value stored at aa.
FABS ANS
r1  r2
r2 is the absolute value of r1.
FACOS ANS
r1  r2
r2 is the principal radian angle whose cosine is r1.
FACOSH ANS
r1  r2
r2 is the floatingpoint value whose hyperbolic cosine is r1.
FALIGN ANS

If the dataspace pointer is not float aligned, reserve enough
data space to make it so.
FALIGNED ANS
ca  aa
aa is the first floataligned address greater than or equal
to ca.
FALOG ANS
r1  r2
Raise ten to the power r1, giving r2.
FASIN ANS
r1  r2
r2 is the principal radian angle whose sine is r1.
FASINH ANS
r1  r2
r2 is the floatingpoint value whose hyperbolic sine is r1.
FATAN ANS
r1  r2
r2 is the principal radian angle whose tangent is r1.
FATAN2 ANS
r1 r2  r3
r3 is the radian angle whose tangent is r1/r2. FSINCOS and
FATAN2 are a complementary pair of operators which convert angles to
2vectors and viceversa. They are essential to most geometric and physical
applications since they correctly and unambiguously handle this conversion in
all cases except null vectors, even when the tangent of the angle would be infinite.
FSINCOS returns a unit
vector in the direction of the given angle, measured counterclockwise from
the positive Xaxis. The order of results on the stack, namely y underneath
x, permits the 2vector data type to be additionally viewed and used as a ratio
approximating the tangent of the angle. Thus the phrase FSINCOS F/ is functionally equivalent to FTAN , but is useful over only a limited and
discontinuous range of angles, whereas FSINCOS
and FATAN2 are useful for all
angles. Vectors in general should appear on the stack in this order.
The argument order for FATAN2
is the same, converting a vector in the conventional representation to
a scalar angle. Thus, for all angles, FSINCOS FATAN2 is an identity within the accuracy of the arithmetic
and the argument range of FSINCOS .
Note that while FSINCOS always returns
a valid unit vector, FATAN2
will accept any nonnull vector.
FATANH ANS
r1  r2
r2 is the floatingpoint value whose hyperbolic tangent is r1.
FCONSTANT ANS
r "<spaces>name" 
Create a definition for name with the execution semantics defined
below. name is referred to as an "fconstant."
name Execution:  r
Place r on the floatingpoint stack. typical use: r FCONSTANT name
FCOS ANS
r1  r2
r2 is the cosine of the radian angle r1.
FCOSH ANS
r1  r2
r2 is the hyperbolic cosine of r1.
FDEPTH ANS
 +n
+n is the current number of possible floatingpoint values contained
on the data stack.
FDROP ANS
r 
Remove r from the floatingpoint stack.
FDUP ANS
r  r r
Duplicate r.
FE. ANS
r 
Display, with a trailing space, the top number on the floatingpoint
stack using engineering notation, where the significand is greater than or equal
to 1.0 and less than 1000.0 and the exponent is a multiple of three. Eg:
12.345E6
FERROR
n 
The word ERROR in the
ANS Forth ROM is revectored to FERROR to
catch floatingpoint errors 42, 43 & 46. These are divide by 0 (FP DIV
0), result out of range (FP RANGE) and invalid argument (FP INV ARG) respectively.
FEXP ANS
r1  r2
Raise e to the power r1, giving r2.
FEXPM1 ANS
r1  r2
Raise e to the power r1 and subtract one, giving r2. This function
allows accurate computation when its arguments are close to zero, and provides
a useful base for the standard exponential functions. Hyperbolic functions such
as cosh(x) can be efficiently and accurately implemented using FEXPM1, accuracy is lost in this function for
small values of x if the word FEXP is used.
An important application of this word is in finance; say a loan is repaid
at 15% per year; what is the daily rate? On a computer with single precision
(six decimal digit) accuracy:
1. Using FLN and FEXP :
FLN of 1.15 = 0.139762, divide by 365
= 3.82910E4, form the exponent using FEXP
= 1.00038, and subtract one (1) and convert to percentage = 0.038%. Thus
we only have two digit accuracy.
2. Using FLNP1 and FEXPM1 :
FLNP1 of 0.15 = 0.139762, (this is
the same value as in the first example, although with the argument closer to
zero it may not be so) divide by 365 = 3.82910E4, form exponent and subtract
one (1) using FEXPM1 = 3.82983E4,
and convert to percentage = 0.0382983%.
This is full six digit accuracy. The presence of this word allows
the hyperbolic functions to be computed with usable accuracy.
FINPUT"
r1  r2
Request a floatingpoint input from the terminal or whatever
input device ACCEPT is revectored to.
Use as:
INPUT" Input a number
: "
It is similar to BASIC's INPUT and will keep asking if an invalid
number is entered.
FINT
r1  r2
r2 is the floating point integer value of r1, rounded towards
0.
FLITERAL ANS
Compilation: r 
Append the runtime semantics given below to the current definition.
Runtime:  r
Place r on the floatingpoint stack.
Typical use:
: X . [ .
(r) ]
FLITERAL . ;
FLN ANS
r1  r2
r2 is the natural logarithm of r1.
FLNP1 ANS
r1  r2
r2 is the natural logarithm of the quantity r1 plus one. This
function allows accurate compilation when its arguments are close to zero, and
provides a useful base for the standard logarithmic functions. See: FEXPM1
FLOAT+ ANS
aa1  aa2
Add the size in address units of a floatingpoint number to
aa1, giving aa2.
FLOATOFF

Restore original vectors executed by ?NUMBER and ERROR . This
must be done before executing an earlier MARKER
word like FP or FP2 . To ensure this FLOATOFF is incorporated into redefinitions
of marker words FP and FP2.
FLOATON

Revector ?NUMBER to F?NUMBER and revector ERROR to
FERROR so that the floatingpoint input can be recognised. FLOATON should be included in the word executed
at powerup in a ROMmed system.
FLOATS ANS
n1  n2
n2 is the size in address units of n1 floatingpoint numbers.
FLOG ANS
r1  r2
r2 is the baseten logarithm of r1.
FLOOR ANS
r1  r2
Round r1 to an integral value using the "round toward negative
infinity" rule, giving r2.
FMAX ANS
r1 r2  r3
r3 is the greater of r1 and r2.
FMIN ANS
r1 r2  r3
r3 is the lesser of r1 and r2.
FNEGATE
ANS
r1  r2
r2 is the negation of r1.
FOVER ANS
r1 r2  r1 r2 r1
Place a copy of r1 on top of the floatingpoint stack.
FP FP2 FP3 FP4 FP5 FP6 FP7
r 
These are MARKER words
to cut back the compiled floating point package.
FP will remove all of it including subsequent definitions. FP3 will leave the files #FP1.TDS and #FP2.TDS
etc.
FROT ANS
r1 r2 r3  r2 r3 r1
Rotate the top three floatingpoint stack entries.
FROUND ANS
r1  r2
Round r1 to an integral value using the "round to nearest" rule,
giving r2.
FS. ANS
r 
Display, with a trailing space, the top number on the floatingpoint
stack in scientific notation:
<significand><exponent>
where:
<significand> := []<digit>.<digits0>
<exponent>
:= E[]<digits>
See: REPRESENT .
FSIN ANS
r1  r2
r2 is the sine of the radian angle r1.
FSINCOS
ANS
r1  r2 r3
r2 is the sine of the radian angle r1. r3 is the cosine of the
radian angle r1. See: FATAN2 .
FSINH ANS
r1  r2
r2 is the hyperbolic sine of r1.
FSQRT ANS
r1  r2
r2 is the square root of r1.
FSWAP ANS
r1 r2  r2 r1
Exchange the top two floatingpoint stack items.
FTAN ANS
r1  r2
r2 is the tangent of the radian angle r1.
FTANH ANS
r1  r2
r2 is the hyperbolic tangent of r1.
FVARIABLE ANS
"<spaces>name" 
Create a definition for name with the execution semantics defined
below. Reserve 6 bytes of data space. name is referred to as an "fvariable."
name Execution:  aa
aa is the address of the data space reserved by FVARIABLE when it created name. A program
is responsible for initialising the contents of the reserved space. Typical
use: FVARIABLE name
F~ ANS
r1 r2 r3  flag
This provides the three types of "floating point equality" in
common use: "close" in absolute terms, exact equality as represented, and "relatively
close".
If r3 is positive, flag is true if the absolute value
of (r1 minus r2) is less than r3.
If r3 is zero, flag is true if the encoding of r1 and
r2 are exactly identical.
If r3 is negative, flag is true if the absolute value
of (r1 minus r2 ) is less than the absolute value of r3 times the sum of the
absolute values of r1 and r2.
PI PI/2 PI/4
 n
Useful floating point constants. PI is 3.1415926 etc.
PRECISION ANS
 u
Return the number of significant digits currently used by F. , FE.
, or FS. as u.
RAD>DEG
r1  r2
r2 is r1 radians converted to degrees.
REPRESENT ANS
r ca u  n flag1 flag2
Provides a primitive for floatingpoint display. At ca, place
the characterstring external representation of the significand of the floatingpoint
number r. Return the decimalbase exponent as n, the sign as flag1 and "valid
result" as flag2. On completion the character string will contain the u most
significant digits of the significand represented as a decimal fraction with
the implied decimal point to the left of the first digit, and the first digit
zero only if all digits are zero. The significand is rounded to u digits following
the "round to nearest" rule; n is adjusted, if necessary, to correspond to the
rounded magnitude of the significand. If flag2 is true then r was in the implementationdefined
range of floatingpoint numbers. If flag1 is true then r is negative.
S>F
n  r
r is the floating point equivalent of 16bit integer n.
SETPRECISION
ANS
u 
Set the number of significant digits currently used by F. ,
FE. , or FS. to u.
SF! ANS
r aa 
Store the floatingpoint number r as a 32bit IEEE singleprecision
number at aa. Since the significand of the internal representation of r has
more precision than the IEEE singleprecision format, it is rounded using the
"round to nearest" rule.
SF@ ANS
aa  r
Fetch the 32bit IEEE singleprecision number stored at aa to
the floatingpoint stack as r in the internal representation.
SFALIGN
ANS

If the dataspace pointer is not singlefloat aligned, reserve
enough data space to make it so.
SFALIGNED ANS
ca  aa
aa is the first singlefloataligned address greater than or
equal to ca.
SFLOAT+
ANS
aa1  aa2
Add the size in address units of a 32bit IEEE singleprecision
number to aa1, giving aa2.
SFLOATS
ANS
n1  n2
n2 is the size in address units of n1 32bit IEEE singleprecision
numbers.
