-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFLOATEXT.FTH
28 lines (26 loc) · 1.03 KB
/
FLOATEXT.FTH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
\ FLOATEXT.FTH floating point extended word set additions
\ Author: Robert van Engelen
DECIMAL
: FSINCOS FDUP FSIN FSWAP FCOS ;
: FALOG 10e FSWAP F** ;
: FCOSH FEXP FDUP 1e FSWAP F/ F+ 2e F/ ;
: FSINH FEXP FDUP 1e FSWAP F/ F- 2e F/ ;
: FTANH FDUP F+ FEXP FDUP 1e F- FSWAP 1e F+ F/ ;
: FACOSH FDUP FDUP F* 1e F- FSQRT F+ FLN ;
: FASINH FDUP FDUP F* 1e F+ FSQRT F+ FLN ;
: FATANH FDUP 1e F+ FSWAP 1e FSWAP F- F/ FLN 2e F/ ;
: FATAN2 ( F: r1 r2 -- r3 )
FDUP F0> IF
F/ FATAN
ELSE FSWAP FDUP F0<> IF
FDUP FSIGN FASIN FROT FROT F/ FATAN F-
ELSE
FDROP F0< S>F FACOS THEN THEN ;
: F~ ( F: r1 r2 r3 -- ; -- flag )
FDUP F0= IF FDROP F= EXIT THEN
FDUP F0< IF FROT FROT FOVER FOVER F- FROT FABS FROT FABS F+ FROT FABS F* F< EXIT THEN
FROT FROT F- FABS F< ;
: FE. ( F: r -- )
HERE PRECISION 3 MAX REPRESENT DROP IF '- EMIT THEN
1- 3 /MOD SWAP DUP 0< IF 3 + SWAP 1- SWAP THEN 1+ HERE OVER TYPE '. EMIT
HERE OVER + SWAP PRECISION SWAP - 0 MAX TYPE 3 * 'E DBL + EMIT . ;