Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #50401
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: fatan2 2012 |
| Date | 2016-08-22 10:00 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2016Aug22.120058@mips.complang.tuwien.ac.at> (permalink) |
| References | <npdse1$1s5g$1@gioia.aioe.org> |
"HAA" <someone@microsoft.com> writes:
>From the PDF ...
>
>12.6.2.1489 FATAN2 "f-a-tan-two" FLOATING EXT
>( F: r1 r2 -- r3 ) or ( r1 r2 -- r3 )
>r3 is the principal radian angle (between -pi and pi ) whose tangent is r1 / r2 .
>A system that returns false for "-0E 0E 0E F~" shall return a value (approximating) -pi
>when r1 = 0E and r2 is negative.
>
>Gforth 0.7.0, Copyright (C) 1995-2008 Free Software Foundation, Inc.
>Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
>Type `bye' to exit
>-0e 0e 0e f~ . 0 ok
>0e -1e fatan2 fs. 3.14159265358979E0 ok
>
>Same for Win32Forth
>
>What should I do now?
>
>I assume there is an error in the test as supplied.
Looking at the proposal <http://www.forth200x.org/fatan2.html>, the
proposed wording is:
|A system which returns FALSE for -0E 0E 0E F~ shall return a value
|(approximating) -pi when r1=-0E and r2 is negative.
The proposal contains tests
\ If y is +/-0 and x is < 0, +/-pi shall be returned.
t{ 0e -1e fatan2 -> pi }t
t{ -0e -1e fatan2 -> -pi }t
and the standard contains the same tests:
\ If y is +/-0 and x is < 0, +/-pi shall be returned.
T{ 0e -1e FATAN2 -> pi R}T
T{ -0e -1e FATAN2 -> -pi R}T
My guess is that the "r1 = 0E" instead of "r1 = -0e" in the standard
is an editorial mistake. Thank you for pointing it out.
>BTW there several 'corner case' tests that could be applied to FATAN2.
>Singling out one with no explanation is only going to leave readers with
>questions when it does fail i.e. what's so special about *this* test.
This is a specification, not a test case. There are many more test
cases in the proposal <http://www.forth200x.org/tests/fatan2.fs> and
the standard <http://forth-standard.org/standard/float/FATANTwo>.
This is one of four cases where there can be two possible results.
Why not the other cases? The proposal does not say, and from what I
remember, nobody asked during the RfD phase.
The proposal contains the following explanation for the second
sentence of the specification:
|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).
>Then there is the reliance on the notorious F~ whose results can be
>right or wrong depending upon your expectations e.g.
>
>SwiftForth i386-Win32 3.6.2 04-Apr-2016
>
>0e pad f! pad 1 floats dump
> 4809E8 00 00 00 00 00 00 00 00 ........ ok
>0e fnegate pad f! pad 1 floats dump
> 4809E8 00 00 00 00 00 00 00 80 ........ ok
>
>0e fdup fnegate 0e f~ . -1 ok
Looks like a bug in SwiftForth's F~ to me.
But apart from that, I did not know that F~ is notorious, even though
it is a Frankenstein-like moster, probably grown out of the desire to
keep the word count small at all costs.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2016: http://www.euroforth.org/ef16/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
fatan2 2012 "HAA" <someone@microsoft.com> - 2016-08-22 13:44 +1000
Re: fatan2 2012 Paul Rubin <no.email@nospam.invalid> - 2016-08-21 21:01 -0700
Re: fatan2 2012 peter.m.falth@gmail.com - 2016-08-22 00:42 -0700
Re: fatan2 2012 anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-22 10:00 +0000
Re: fatan2 2012 "HAA" <someone@microsoft.com> - 2016-08-23 12:51 +1000
Re: fatan2 2012 anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-23 11:11 +0000
Re: fatan2 2012 "HAA" <someone@microsoft.com> - 2016-08-25 02:16 +1000
Re: fatan2 2012 albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-02 18:03 +0200
Re: fatan2 2012 Paul Rubin <no.email@nospam.invalid> - 2016-09-02 12:02 -0700
csiph-web