Node:Floating point stack, Next:Return stack, Previous:Data stack, Up:Stack Manipulation
Whilst every sane Forth has a separate floating-point stack, it is not
strictly required; an ANS Forth system could theoretically keep
floating-point numbers on the data stack. As an additional difficulty,
you don't know how many cells a floating-point number takes. It is
reportedly possible to write words in a way that they work also for a
unified stack model, but we do not recommend trying it. Instead, just
say that your program has an environmental dependency on a separate
floating-point stack.
floating-stack
-- n environment ``floating-stack''
n is non-zero, showing that Gforth maintains a separate
floating-point stack of depth n.
fdrop
r -- float ``f-drop''
fnip
r1 r2 -- r2 gforth ``f-nip''
fdup
r -- r r float ``f-dupe''
fover
r1 r2 -- r1 r2 r1 float ``f-over''
ftuck
r1 r2 -- r2 r1 r2 gforth ``f-tuck''
fswap
r1 r2 -- r2 r1 float ``f-swap''
fpick
u -- r gforth ``fpick''
Actually the stack effect is r0 ... ru u -- r0 ... ru r0
.
frot
r1 r2 r3 -- r2 r3 r1 float ``f-rote''