 Foreword
 Proposals Process
 200x Membership
 1 Introduction
 2 Terms, notation, and references
 3 Usage requirements
 4 Documentation requirements
 5 Compliance and labeling
 6 Glossary
 7 The optional Block word set
 8 The optional DoubleNumber word set
 9 The optional Exception word set
 10 The optional Facility word set
 11 The optional FileAccess word set
 12 The optional FloatingPoint word set
 DFALIGN
 DFALIGNED
 DFFIELD:
 DF@
 DFLOAT+
 DFLOATS
 DF!
 D>F
 FABS
 FACOS
 FACOSH
 FALIGN
 FALIGNED
 FALOG
 FASIN
 FASINH
 FATAN
 FATANH
 FATAN2
 FCONSTANT
 FCOS
 FCOSH
 FDEPTH
 FDROP
 FDUP
 F/
 FEXP
 FEXPM1
 FE.
 FFIELD:
 F@
 FLITERAL
 FLN
 FLNP1
 FLOAT+
 FLOATS
 FLOG
 FLOOR
 FMAX
 FMIN
 F
 FNEGATE
 FOVER
 F+
 FROT
 FROUND
 FSIN
 FSINCOS
 FSINH
 FSQRT
 FSWAP
 FS.
 F!
 FTAN
 FTANH
 FTRUNC
 F*
 F**
 FVALUE
 FVARIABLE
 F0=
 F0<
 F.
 F<
 F~
 F>D
 F>S
 PRECISION
 REPRESENT
 SETPRECISION
 SFALIGN
 SFALIGNED
 SFFIELD:
 SF@
 SFLOAT+
 SFLOATS
 SF!
 S>F
 >FLOAT
 13 The optional Locals word set
 14 The optional MemoryAllocation word set
 15 The optional ProgrammingTools word set
 16 The optional SearchOrder word set
 17 The optional String word set
 18 The optional ExtendedCharacter word set
 Annex A: Rationale
 Annex B: Bibliography
 Annex C: Compatibility analysis
 Annex D: Portability guide
 Annex E: Reference Implementations
 Annex F: Test Suite
 Annex H: Alphabetic list of words
12 The optional FloatingPoint word set
12.1 Introduction
12.2 Additional terms and notation
12.2.1 Definition of terms
 floataligned address:

The address of a memory location at which a floatingpoint
number can be accessed.
 doublefloataligned address:

The address of a memory location at which a 64bit IEEE
doubleprecision floatingpoint number can be accessed.
 singlefloataligned address:

The address of a memory location at which a 32bit IEEE
singleprecision floatingpoint number can be accessed.
 IEEE floatingpoint number:
 A single or doubleprecision floatingpoint number as defined in ANSI/IEEE 7541985.
12.2.2 Notation
12.2.2.2 Stack notation
Floatingpoint stack notation is:A unified stack notation is provided for systems with the environmental restriction that the floatingpoint numbers are kept on the data stack.
12.3 Additional usage requirements
12.3.1 Data types
Append table 12.1 to table 3.1.
Symbol  Data type  Size on stack 
dfaddr  doublefloataligned address  1 cell 
faddr  floataligned address  1 cell 
r  floatingpoint number  implementationdefined 
sfaddr  singlefloataligned address  1 cell 
12.3.1.1 Addresses
The set of floataligned addresses is an implementationdefined subset of the set of aligned addresses. Adding the size of a floatingpoint number to a floataligned address shall produce a floataligned address.
The set of doublefloataligned addresses is an implementationdefined subset of the set of aligned addresses. Adding the size of a 64bit IEEE doubleprecision floatingpoint number to a doublefloataligned address shall produce a doublefloataligned address.
The set of singlefloataligned addresses is an implementationdefined subset of the set of aligned addresses. Adding the size of a 32bit IEEE singleprecision floatingpoint number to a singlefloataligned address shall produce a singlefloataligned address.
12.3.1.2 Floatingpoint numbers
The internal representation of a floatingpoint number, including the format and precision of the significand and the format and range of the exponent, is implementation defined.
Any rounding or truncation of floatingpoint numbers is implementation defined.
12.3.2 Floatingpoint operations
"Round to nearest" means round the result of a floatingpoint operation to the representable value nearest the result. If the two nearest representable values are equally near the result, the one having zero as its least significant bit shall be delivered.
"Round toward negative infinity" means round the result of a floatingpoint operation to the representable value nearest to and no greater than the result.
"Round toward zero" means round the result of a floatingpoint operation to the representable value nearest to zero, frequently referred to as "truncation".
12.3.3 Floatingpoint stack
A last in, first out list that shall be used by all floatingpoint operators.
The width of the floatingpoint stack is implementationdefined. The floatingpoint stack shall be separate from the data and return stacks.
The size of a floatingpoint stack shall be at least 6 items.
A program that depends on the floatingpoint stack being larger than six items has an environmental dependency.
12.3.4 Environmental queries
Append table 12.2 to table 3.4.See: 3.2.6 Environmental queries.
String Value data type  Constant?  Meaning  
FLOATINGSTACK  n  yes  the maximum depth of the separate floatingpoint stack. On systems with the environmental restriction of keeping floatingpoint items on the data stack, n = 0. 
MAXFLOAT  r  yes  largest usable floatingpoint number 
12.3.5 Address alignment
Since the address returned by a CREATEd word is not necessarily aligned for any particular class of floatingpoint data, a program shall align the address (to be float aligned, singlefloat aligned, or doublefloat aligned) before accessing floatingpoint data at the address.See: 3.3.3.1 Address alignment, 12.3.1.1 Addresses.
12.3.6 Variables
A program may address memory in data space regions made available by FVARIABLE. These regions may be noncontiguous with regions subsequently allocated with , (comma) or ALLOT. See: 3.3.3.3 Variables.
12.3.7 Text interpreter input number conversion
If the FloatingPoint word set is present in the dictionary and the current base is DECIMAL, the input numberconversion algorithm shall be extended to recognize floatingpoint numbers in this form:
Convertible string  :=  <significand><exponent> 
<significand>  :=  [<sign>]<digits>[.<digits0>] 
<exponent>  :=  E[<sign>]<digits0> 
<sign>  :=  { +   } 
<digits>  :=  <digit><digits0> 
<digits0>  :=  <digit>* 
<digit>  :=  { 0  1  2  3  4  5  6  7  8  9 } 
These are examples of valid representations of floatingpoint numbers in program source:
1E 1.E 1.E0 +1.23E1 1.23E+1
See: 3.4.1.3 Text interpreter input number conversion, 12.6.1.0558 >FLOAT.
12.4 Additional documentation requirements
12.4.1 System documentation
12.4.1.1 Implementationdefined options
 format and range of floatingpoint numbers (12.3.1 Data types, 12.6.1.2143 REPRESENT);
 results of 12.6.1.2143 REPRESENT when float is out of range;
 rounding or truncation of floatingpoint numbers (12.3.1.2 Floatingpoint numbers);
 size of floatingpoint stack (12.3.3 Floatingpoint stack);
 width of floatingpoint stack (12.3.3 Floatingpoint stack).
12.4.1.2 Ambiguous conditions
 DF@ or DF! is used with an address that is not doublefloat aligned;
 F@ or F! is used with an address that is not float aligned;
 floating point result out of range (e.g., in 12.6.1.1430 F/);
 SF@ or SF! is used with an address that is not singlefloat aligned;
 BASE is not decimal (12.6.1.2143 REPRESENT, 12.6.2.1427 F., 12.6.2.1513 FE., 12.6.2.1613 FS.);
 both arguments equal zero (12.6.2.1489 FATAN2);
 cosine of argument is zero for 12.6.2.1625 FTAN;
 d can't be precisely represented as float in 12.6.1.1130 D>F;
 dividing by zero (12.6.1.1430 F/);
 exponent too big for conversion (12.6.2.1203 DF!, 12.6.2.1204 DF@, 12.6.2.2202 SF!, 12.6.2.2203 SF@);
 float less than one (12.6.2.1477 FACOSH);
 float less than or equal to minusone (12.6.2.1554 FLNP1);
 float less than or equal to zero (12.6.2.1553 FLN, 12.6.2.1557 FLOG);
 float less than zero (12.6.2.1618 FSQRT);
 float magnitude greater than one (12.6.2.1476 FACOS, 12.6.2.1486 FASIN, 12.6.2.1491 FATANH);
 integer part of float can't be represented by d in 12.6.1.1470 F>D;
 string larger than picturednumeric output area (12.6.2.1427 F., 12.6.2.1513 FE., 12.6.2.1613 FS.);
 n can't be precisely represented as float in 12.6.2.2175 S>F;
 integer part of float can't be represented by n in 12.6.2.1471 F>S.
12.4.1.3 Other system documentation
 no additional requirements.
12.4.1.4 Environmental restrictions
 Keeping floatingpoint numbers on the data stack.
12.4.2 Program documentation
12.4.2.1 Environmental dependencies
 requiring the floatingpoint stack to be larger than six items (12.3.3 Floatingpoint stack);
 requiring floatingpoint numbers to be kept on the data stack, with n cells per floating point number.
12.4.2.2 Other program documentation
 no additional requirements.
12.5 Compliance and labeling
12.5.1 Forth2012 systems
The phrase "Providing the FloatingPoint word set" shall be appended to the label of any Standard System that provides all of the FloatingPoint word set.The phrase "Providing name(s) from the FloatingPoint Extensions word set" shall be appended to the label of any Standard System that provides portions of the FloatingPoint Extensions word set.
The phrase "Providing the FloatingPoint Extensions word set" shall be appended to the label of any Standard System that provides all of the FloatingPoint and FloatingPoint Extensions word sets.
12.5.2 Forth2012 programs
The phrase "Requiring the FloatingPoint word set" shall be appended to the label of Standard Programs that require the system to provide the FloatingPoint word set.The phrase "Requiring name(s) from the FloatingPoint Extensions word set" shall be appended to the label of Standard Programs that require the system to provide portions of the FloatingPoint Extensions word set.
The phrase "Requiring the FloatingPoint Extensions word set" shall be appended to the label of Standard Programs that require the system to provide all of the FloatingPoint and FloatingPoint Extensions word sets.
12.6 Glossary
12.6.1 FloatingPoint words
 12.6.1.0558 >FLOAT
 12.6.1.1130 D>F
 12.6.1.1400 F!
 12.6.1.1410 F*
 12.6.1.1420 F+
 12.6.1.1425 F
 12.6.1.1430 F/
 12.6.1.1440 F0<
 12.6.1.1450 F0=
 12.6.1.1460 F<
 12.6.1.1470 F>D
 12.6.1.1472 F@
 12.6.1.1479 FALIGN
 12.6.1.1483 FALIGNED
 12.6.1.1492 FCONSTANT
 12.6.1.1497 FDEPTH
 12.6.1.1500 FDROP
 12.6.1.1510 FDUP
 12.6.1.1552 FLITERAL
 12.6.1.1555 FLOAT+
 12.6.1.1556 FLOATS
 12.6.1.1558 FLOOR
 12.6.1.1562 FMAX
 12.6.1.1565 FMIN
 12.6.1.1567 FNEGATE
 12.6.1.1600 FOVER
 12.6.1.1610 FROT
 12.6.1.1612 FROUND
 12.6.1.1620 FSWAP
 12.6.1.1630 FVARIABLE
 12.6.1.2143 REPRESENT
12.6.2 FloatingPoint extension words
 12.6.2.1203 DF!
 12.6.2.1204 DF@
 12.6.2.1205 DFALIGN
 12.6.2.1207 DFALIGNED
 12.6.2.1207.40 DFFIELD:
 12.6.2.1208 DFLOAT+
 12.6.2.1209 DFLOATS
 12.6.2.1415 F**
 12.6.2.1427 F.
 12.6.2.1471 F>S
 12.6.2.1474 FABS
 12.6.2.1476 FACOS
 12.6.2.1477 FACOSH
 12.6.2.1484 FALOG
 12.6.2.1486 FASIN
 12.6.2.1487 FASINH
 12.6.2.1488 FATAN
 12.6.2.1489 FATAN2
 12.6.2.1491 FATANH
 12.6.2.1493 FCOS
 12.6.2.1494 FCOSH
 12.6.2.1513 FE.
 12.6.2.1515 FEXP
 12.6.2.1516 FEXPM1
 12.6.2.1517 FFIELD:
 12.6.2.1553 FLN
 12.6.2.1554 FLNP1
 12.6.2.1557 FLOG
 12.6.2.1613 FS.
 12.6.2.1614 FSIN
 12.6.2.1616 FSINCOS
 12.6.2.1617 FSINH
 12.6.2.1618 FSQRT
 12.6.2.1625 FTAN
 12.6.2.1626 FTANH
 12.6.2.1627 FTRUNC
 12.6.2.1628 FVALUE
 12.6.2.1640 F~
 12.6.2.2035 PRECISION
 12.6.2.2175 S>F
 12.6.2.2200 SETPRECISION
 12.6.2.2202 SF!
 12.6.2.2203 SF@
 12.6.2.2204 SFALIGN
 12.6.2.2206 SFALIGNED
 12.6.2.2206.40 SFFIELD:
 12.6.2.2207 SFLOAT+
 12.6.2.2208 SFLOATS
ContributeContributions
JennyBrien Mistake in the specification of significand?Example20160703 16:20:50
Convertible string := <significand><exponent>
<significand> := [<sign>]<digits>[.<digits0>]
<exponent> := E[<sign>]<digits0>
<sign> := { +   }
<digits> := <digit><digits0>
<digits0> := <digit>*
<digit> := { 0  1  2  3  4  5  6  7  8  9 }
Surely it should be [<sign>]<digit>[.<digits0>] ? Only one digit allowed before the decimal point?
zhtoor Implementations requiring BOTH 32 bit single floats and 64 bit double floats.Proposal20161221 14:39:40
Here the problem arises that what kind of floats are referred to by F F/ etc., single (32bit) or double (64bit). so would it not be better to use two naming standards for both the precisions such as G G/ for double operations, C C/ for single complex numbers and Z Z/ for double complex numbers. please advise.
kc5tja F>R and FR> to support dynamicallyscoped floating point variablesProposal20190303 06:20:52
In writing an implementation of map and reduce operations for some floating point vectors, I've had a need to save and restore dynamic variables on the Rstack. Some of these variables are floating point variables.
The lack of a floatingpoint stack equivalent to R> and >R made this more difficult than it should have been, I think. Therefore, I'd like to propose the following two words for consideration in the FLOATINGEXT wordset:
Word  Runtime Semantics 

F>R 
Pushes the top of the floating point stack onto the return stack. 
FR> 
Pops the return stack, pushing the value removed onto the floating point stack. 
On systems where the return stack cell size differs from the floating point stack cell size, multiple cells may need to be pushed onto the Rstack, padding as appropriate. Because of alignment issues, FR>
and F>R
are not guaranteed to be fast, as the implementation may have to store the floating point value in smaller parcels (e.g., storing a 64bit or 80bit FP value as a series of 16bit cells on a 16bit Forth).
Here's my current implementation written in 64bit GForth 0.7.0 on x8664 platform:
FVARIABLE realvar
: F>R ( r  ) ( R:  r ) R> realvar F! realvar @ >R >R ;
: FR> ( R: r  ) (  r ) R> R> realvar ! realvar F@ >R ;
I'd love to hear your thoughts. Thanks for entertaining my idea.