forked from Forth-Standard/forth200x
/
fatan2.html
186 lines (141 loc) · 6.43 KB
/
fatan2.html
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<title>Ambiguity in FATAN2</title>
<h3>Ambiguity in FATAN2</h3>
<h4>Poll standings</h4>
See <a href="#voting">below</a> for voting instructions.
<h5>Systems</h5>
<pre>
[ ] conforms to ANS Forth.
iForth (Marcel Hendrix)
VFX Forth for Windows, Linux, DOS (Stephen Pelc)
[ ] already implements the proposal in full since release [ ].
iForth 0 (Marcel Hendrix)
4th 3.5d with ANS Float (Hans Bezemer)
VFX Forth for Windows, Linux, DOS 3.7 (Stephen Pelc)
[ ] implements the proposal in full in a development version.
4th with ZEN Float (Hans Bezemer)
[ ] will implement the proposal in full in release [ ].
[ ] will implement the proposal in full in some future release.
[ ] There are no plans to implement the proposal in full in [ ].
[ ] will never implement the proposal in full.
</pre>
<h5>Programmers</h5>
<pre>
[ ] I have used (parts of) this proposal in my programs.
David N. Williams
Marcel Hendrix
Hans Bezemer
[ ] I would use (parts of) this proposal in my programs if the systems
I am interested in implemented it.
David N. Williams
Marcel Hendrix
[ ] I would use (parts of) this proposal in my programs if this
proposal was in the Forth standard.
David N. Williams
Marcel Hendrix
Ed Falat
[ ] I would not use (parts of) this proposal in my programs.
</pre>
<h5>Informal results</h5>
John Wallace writes:
<pre>
This problem has plagued one of my programs for quite along time since
1982. Just in the last month I figured out why it is not a problem
in nature. It is quantized, you 2,3,4 etc. n principle values only.
</pre>
<h4>Proposal</h4>
<pre>
Author: Charles G. Montgomery
Problem
The ANS definition is:
12.6.2.1489 FATAN2
f-a-tan-two FLOATING EXT ( F: r1 r2 -- r3 ) or ( r1 r2 -- r3 )
r3 is the radian angle whose tangent is r1/r2. An ambiguous condition
exists if r1 and r2 are zero.
This is incomplete, since it does not specify which of the countably
infinite set of angles satisfying this specification will be returned as r3.
Other computer languages which provide this function commonly specify the
"principal angle", the one between -pi and pi.
Proposal
The first sentence of the definition should be expanded to:
r3 is the principal radian angle (between -pi and pi)
whose tangent is r1/r2.
Another sentence should be added:
A system which returns FALSE for -0E 0E 0E F~ shall return a value
(approximating) -pi when r1=-0E and r2 is negative.
Remarks
This rewording follows the suggestion by Peter Knaggs that the language
follow the pattern used in the definition of FACOS, FASIN, and FATAN (but
with an added clarification of the term "principal").
Discussions in comp.lang.forth have included general agreement that the
present definition is ambiguous, probably unintentionally, and that specifying
the principal angle would be the favored correction.
The second sentence calls for behavior similar to other languages, such as C
and Fortran, is consistent with much modern hardware, and its omission would
impose an unnecessary burden on system providers, since most systems supporting
negative zero follow IEEE floating point behavior which behaves this way.
The wording of the second sentence has been chosen to be unambiguous without
the need for any new environmental query (even if F~ does not behave properly).
It has been suggested that additional Forth200x extensions be added to cover
support for negative zeros or perhaps general IEEE floating point behavior.
If such extensions become accepted and provide an environmental query that
would be useful for specifying the bahavior of FATAN2, it would be very easy
to make (yet another) modification to the specification of FATAN2, to make use
of them.
Experience
A summary quoted from a posting by David N. Williams in comp.lang.forth:
FATAN2 CONVENTIONS
implementation -pi to pi 0 to 2pi
--------------------------------------
pfe 0.33.70 yes no
gforth 0.7.0 yes no
kforth 1.4.0 yes no
iForth 3.0.3 yes no
4tH 3.5c yes no
SwiftForth 3 no yes
VFX Forth 4 yes no
Win32Forth 6.13.00 yes no
Testing
<a href="tests/fatan2.fs">Tests</a>
</pre>
<h4><a name="voting">Voting instructions</a></h4>
Fill out the appropriate ballot(s) below and mail it/them to me
<anton@mips.complang.tuwien.ac.at>. Your vote will be published
(including your name (without email address) and/or the name of your
system) here. You can vote (or change your vote) at any time by
mailing to me, and the results will be published here.
<p>Note that you can be both a system implementor and a programmer, so
you can submit both kinds of ballots.
<h5>Ballot for systems</h5>
If you maintain several systems, please mention the systems separately
in the ballot. Insert the system name or version between the brackets
or in the line below the statement. Multiple hits for the same system
are possible (if they do not conflict).
<pre>
[ ] conforms to ANS Forth.
[ ] already implements the proposal in full since release [ ].
[ ] implements the proposal in full in a development version.
[ ] will implement the proposal in full in release [ ].
[ ] will implement the proposal in full in some future release.
[ ] There are no plans to implement the proposal in full in [ ].
[ ] will never implement the proposal in full.
</pre>
If you want to provide information on partial implementation, please do
so informally, and I will aggregate this information in some way.
<h5>Ballot for programmers</h5>
Just mark the statements that are correct for you (e.g., by putting
your name on the line below the statement you agree with). If some
statements are true for some of your programs, but not others, please
mark the statements for the dominating class of programs you write.
<pre>
[ ] I have used (parts of) this proposal in my programs.
[ ] I would use (parts of) this proposal in my programs if the systems
I am interested in implemented it.
[ ] I would use (parts of) this proposal in my programs if this
proposal was in the Forth standard.
[ ] I would not use (parts of) this proposal in my programs.
</pre>
If you feel that there is closely related functionality missing from the
proposal (especially if you have used that in your programs), make an
informal comment, and I will collect these, too. Note that the best time
to voice such issues is the RfD stage.
<hr><a href="http://www.complang.tuwien.ac.at/anton/">Anton Ertl</a>