The format of floating point numbers recognized by the outer (aka text)
interpreter is: a signed decimal number, possibly containing a decimal
.), followed by
e, optionally followed
by a signed integer (the exponent). E.g.,
1e is the same as
+1.0e+0. Note that a number without
e is not interpreted
as floating-point number, but as double (if the number contains a
.) or single precision integer. Also, conversions between string
and floating point numbers always use base 10, irrespective of the value
BASE (in Gforth; for the standard this is an ambiguous
BASE contains a value greater then 14, the
E may be interpreted as digit and the number will be interpreted
as integer, unless it has a signed exponent (both
are allowed as signs).
Angles in floating point operations are given in radians (a full circle has 2 pi radians). Note, that Gforth has a separate floating point stack, but we use the unified notation.
Floating point numbers have a number of unpleasant surprises for the unwary (e.g., floating point addition is not associative) and even a few for the wary. You should not use them unless you know what you are doing or you don't care that the results you get are totally bogus. If you want to learn about the problems of floating point numbers (and how to avoid them), you might start with David Goldberg, What Every Computer Scientist Should Know About Floating-Point Arithmetic, ACM Computing Surveys 23(1):5-48, March 1991 (http://www.validgh.com/goldberg/paper.ps).
f+r1 r2 -- r3 float ``f-plus''
f-r1 r2 -- r3 float ``f-minus''
f*r1 r2 -- r3 float ``f-star''
f/r1 r2 -- r3 float ``f-slash''
fnegater1 -- r2 float ``fnegate''
fabsr1 -- r2 float-ext ``fabs''
fmaxr1 r2 -- r3 float ``fmax''
fminr1 r2 -- r3 float ``fmin''
floorr1 -- r2 float ``floor''
round towards the next smaller integral value, i.e., round toward negative infinity
froundr1 -- r2 float ``fround''
round to the nearest integral value
f**r1 r2 -- r3 float-ext ``f-star-star''
r3 is r1 raised to the r2th power
fsqrtr1 -- r2 float-ext ``fsqrt''
fexpr1 -- r2 float-ext ``fexp''
fexpm1r1 -- r2 float-ext ``fexpm1''
flnr1 -- r2 float-ext ``fln''
flnp1r1 -- r2 float-ext ``flnp1''
flogr1 -- r2 float-ext ``flog''
the decimal logarithm
falogr1 -- r2 float-ext ``falog''
fsinr1 -- r2 float-ext ``fsin''
fcosr1 -- r2 float-ext ``fcos''
fsincosr1 -- r2 r3 float-ext ``fsincos''
ftanr1 -- r2 float-ext ``ftan''
fasinr1 -- r2 float-ext ``fasin''
facosr1 -- r2 float-ext ``facos''
fatanr1 -- r2 float-ext ``fatan''
fatan2r1 r2 -- r3 float-ext ``fatan2''
r1/r2=tanr3. The standard does not require, but probably
intends this to be the inverse of
fsincos. In gforth it is.
fsinhr1 -- r2 float-ext ``fsinh''
fcoshr1 -- r2 float-ext ``fcosh''
ftanhr1 -- r2 float-ext ``ftanh''
fasinhr1 -- r2 float-ext ``fasinh''
facoshr1 -- r2 float-ext ``facosh''
fatanhr1 -- r2 float-ext ``fatanh''
Go to the first, previous, next, last section, table of contents.