12.24Floating point configurations. 4tH 4tH Forth compiler
Advertentie
Advertentie
CHAPTER 12. STANDARD LIBRARIES
F
AMILY
FSIN
FEXP
FLN
FERF
F
ILE fsinfcos.4th
fsincost.4th
fexp.4th
fexpt.4th
flnflog.4th
flnflogb.4th
ferf.4th
erf1.4th
erf.4th
D
E
-
FAULT
Y
N
N/A
N/A
N/A
Y
N
Y
N
S
PEED
+ o
+
-
-
+ o
+
+
A
CCU
RACY o
-
+
+
+
+ o
+ o
-
Table 12.10: ANS-Forth functions
S
IZE
A
LGORITHM
+
+ o
+ o
+
+ o
-
Remez
Taylor
Remez
Taylor
Remez
Brute force
Taylor, approx.
Approximation
Chebyshev
198
Note several ANS-Forth floating point libraries are used within other libraries. If a library is marked ”default”, it is the default that will be selected for inclusion if you haven’t included another library already. Most of the time you can override the default selection by simply explicitly including it, e.g. instead of: include lib/ansfloat.4th
include lib/ansfpio.4th
include lib/fexpint.4th
You could set up the program like this: include lib/ansfloat.4th
include lib/ansfpio.4th
include lib/fexpt.4th
include lib/flnflogb.4th
include lib/fexpint.4th
In some cases a library member may assume a certain dependency is already resolved and bomb out. In that case, you’ll have to figure out yourself which dependency that is and resolve it manually. If that happens, you may find chapter 23.2 quite useful.
12.24
Floating point configurations
In order to simplify setting up floating point support, there are five predefined configurations. The only thing you have to do is to include a single file. All configurations support basic floating point operations and floating point I/O. You can see in the table which configuration meets your particular needs.
For your information: precision is definitely not the same thing as accuracy. If you’re still not sure what to choose configuration 2 (fp2.4th) is a safe bet. Note that ”FLOAT” is always defined when having included any of the configurations, which enables you to check whether floating point support has been loaded, e.g.:
[UNDEFINED] float [IF] [ABORT] [THEN]
If you need to differentiate between Zen floating point or ANS floating point, you just have to check whether the constant ”ZENFP” has been defined, e.g.:
Downloaden
Advertentie