forked from scx/wxmaxima-flatpak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecl-16.1.3-atan.patch
126 lines (124 loc) · 3.54 KB
/
ecl-16.1.3-atan.patch
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
--- src/c/numbers/atan.d.orig 2016-12-19 03:25:00.000000000 -0700
+++ src/c/numbers/atan.d 2017-02-23 11:03:32.602020581 -0700
@@ -22,27 +22,29 @@
static double
ecl_atan2_double(double y, double x)
{
- if (signbit(x)) {
- if (signbit(y)) {
- return -ECL_PI_D + atan(-y / -x);
- } else if (y == 0) {
- return ECL_PI_D;
- } else {
- return ECL_PI_D - atan(y / -x);
- }
- } else if (x == 0) {
- if (signbit(y)) {
+ if (x == 0) {
+ if (y == 0) {
+ /* Signals floating-point-invalid operation. If not trapped,
+ produces NaN. */
+ return x / y;
+ } else if (signbit(y)) {
return -ECL_PI2_D;
- } else if (y == 0) {
- return x / y; /* Produces a NaN */
} else {
return ECL_PI2_D;
}
+ } else if (signbit(x)) {
+ if (y == 0) {
+ return ECL_PI_D;
+ } else if (signbit(y)) {
+ return -ECL_PI_D + atan(-y / -x);
+ } else {
+ return ECL_PI_D - atan(y / -x);
+ }
} else {
- if (signbit(y)) {
- return -atan(-y / x);
- } else if (y == 0) {
+ if (y == 0) {
return (double)0;
+ } else if (signbit(y)) {
+ return -atan(-y / x);
} else {
return atan(y / x);
}
@@ -53,27 +55,29 @@ ecl_atan2_double(double y, double x)
static long double
ecl_atan2_long_double(long double y, long double x)
{
- if (signbit(x)) {
- if (signbit(y)) {
- return -ECL_PI_L + atanl(-y / -x);
- } else if (y == 0) {
- return ECL_PI_L;
- } else {
- return ECL_PI_L - atanl(y / -x);
- }
- } else if (x == 0) {
- if (signbit(y)) {
+ if (x == 0) {
+ if (y == 0) {
+ /* Signals floating-point-invalid-operation. If not trapped,
+ produces NaN. */
+ return x / y;
+ } else if (signbit(y)) {
return -ECL_PI2_L;
- } else if (y == 0) {
- return x / y; /* Produces a NaN */
} else {
return ECL_PI2_L;
}
+ } else if (signbit(x)) {
+ if (y == 0) {
+ return ECL_PI_L;
+ } else if (signbit(y)) {
+ return -ECL_PI_L + atanl(-y / -x);
+ } else {
+ return ECL_PI_L - atanl(y / -x);
+ }
} else {
- if (signbit(y)) {
- return -atanl(-y / x);
- } else if (y == 0) {
+ if (y == 0) {
return (long double)0;
+ } else if (signbit(y)) {
+ return -atanl(-y / x);
} else {
return atanl(y / x);
}
--- src/tests/normal-tests/mixed.lsp.orig 2016-12-19 03:25:00.000000000 -0700
+++ src/tests/normal-tests/mixed.lsp 2017-02-23 10:56:00.028415503 -0700
@@ -178,7 +178,7 @@
;;;; Created: 2016-09-07
;;;; Contains: External process interaction API
;;;;
-(test external-process.0001.run-program
+(test mix.0011.run-program
(let ((p (nth-value 2 (ext:run-program #-windows "sleep"
#+windows "timeout"
(list "3") :wait nil))))
@@ -195,3 +195,22 @@
(finishes (ext:terminate-process p))))
+;;; Date: 2016-12-20
+;;; Reported by: Kris Katterjohn
+;;; Fixed: Daniel Kochmański
+;;; Description:
+;;;
+;;; atan signalled `division-by-zero' exception when the second
+;;; argument was signed zero. Also inconsistent behavior on invalid
+;;; operation (atan 0.0 0.0).
+;;;
+;;; Bug: https://gitlab.com/embeddable-common-lisp/ecl/issues/329
+(test mix.0012.atan-signed-zero
+ (finishes (atan 1.0 -0.0))
+ (signals floating-point-invalid-operation (atan -0.0 -0.0))
+ (signals floating-point-invalid-operation (atan +0.0 -0.0))
+ (signals floating-point-invalid-operation (atan -0.0 +0.0))
+ (signals floating-point-invalid-operation (atan +0.0 +0.0)))
+
+
+