The HTML version of this proposal is at
<http://www.forth200x.org/fp-stack.html>.
Problem
Writing floating-point code such that it can run on a unified stack is
such a pain that most programmers don't do it.
Proposal
The floating-point stack is separate from the data stack.
Typical Use
\ from <126r7o1srr8aof0@...>
: square ( f - f') fdup f* ;
: pow ( n) ( f - f')
?dup 0= if fdrop 1e0 exit then
dup 1 = if drop exit then
2 /mod fdup square recurse fswap recurse f* ;
Experience
All ANS Forth systems that I know implement a separate floating-point
stack. Kforth implements a subset of ANS Forth subset and has a
unified FP stack.
All ANS Forth programs dealing with FP numbers that I know except code
written specifically for kforth just assumes a separate floating-point
stack.
Implementation and Tests
o Incomplete Implementation
<http://www.forth200x.org/reference-implementations/fp-stack.fs>;
the main missing piece is the (system-specific) text-interpreter
floating-point input.
o No tests yet
- anton