View | Details | Raw Unified | Return to bug 218514 | Differences between
and this patch

Collapse All | Expand All

(-)b/lib/msun/ld128/s_sinpil.c (-13 / +16 lines)
Lines 1-5 Link Here
1
/*-
1
/*-
2
 * Copyright (c) 2017 Steven G. Kargl
2
 * Copyright (c) 2017-2021 Steven G. Kargl
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
Lines 26-34 Link Here
26
26
27
/*
27
/*
28
 * See ../src/s_sinpi.c for implementation details.
28
 * See ../src/s_sinpi.c for implementation details.
29
 *
30
 * FIXME:  This has not been compiled nor has it been tested for accuracy.
31
 * FIXME:  This should use bit twiddling.
32
 */
29
 */
33
30
34
#include "math.h"
31
#include "math.h"
Lines 68-74 sinpil(long double x) Link Here
68
			}
65
			}
69
66
70
			s = __kernel_sinpil(ax);
67
			s = __kernel_sinpil(ax);
71
			return (copysignl(s, x));
68
			return (x < 0 ? -s : s);
72
		}
69
		}
73
70
74
		if (ax < 0.5)
71
		if (ax < 0.5)
Lines 77-88 sinpil(long double x) Link Here
77
			s = __kernel_cospil(ax - 0.5);
74
			s = __kernel_cospil(ax - 0.5);
78
		else
75
		else
79
			s = __kernel_sinpil(1 - ax);
76
			s = __kernel_sinpil(1 - ax);
80
		return (copysignl(s, x));
77
		return (x < 0 ? -s : s);
81
	}
78
	}
82
79
83
	if (ax < 0x1p112) {
80
	if (ax < 0x1p112) {
84
		xf = floorl(ax);
81
		/* Split x = n + r with 0 <= r < 1. */
85
		ax -= xf;
82
		xf = (ax + 0x1p112L) - 0x1p112L;        /* Integer part */
83
		ax -= xf;                               /* Remainder */
84
		if (ax < 0) {
85
			ax += 1;
86
			xf -= 1;
87
		}
88
86
		if (ax == 0) {
89
		if (ax == 0) {
87
			s = 0;
90
			s = 0;
88
		} else {
91
		} else {
Lines 98-111 sinpil(long double x) Link Here
98
					s = __kernel_sinpil(1 - ax);
101
					s = __kernel_sinpil(1 - ax);
99
			}
102
			}
100
103
101
			if (xf > 0x1p50)
104
			if (xf > 0x1p64)
102
				xf -= 0x1p50;
105
				xf -= 0x1p64;
103
			if (xf > 0x1p30)
106
			if (xf > 0x1p32)
104
				xf -= 0x1p30;
107
				xf -= 0x1p32;
105
			ix = (uint32_t)xf;
108
			ix = (uint32_t)xf;
106
			if (ix & 1) s = -s;
109
			if (ix & 1) s = -s;
107
		}
110
		}
108
		return (copysignl(s, x));
111
		return (x < 0 ? -s : s);
109
	}
112
	}
110
113
111
	if (isinf(x) || isnan(x))
114
	if (isinf(x) || isnan(x))
(-)b/lib/msun/ld128/s_cospil.c (-14 / +17 lines)
Lines 1-5 Link Here
1
/*-
1
/*-
2
 * Copyright (c) 2017 Steven G. Kargl
2
 * Copyright (c) 2017-2021 Steven G. Kargl
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
Lines 26-34 Link Here
26
26
27
/*
27
/*
28
 * See ../src/s_cospi.c for implementation details.
28
 * See ../src/s_cospi.c for implementation details.
29
 *
30
 * FIXME:  This has not been compiled nor has it been tested for accuracy.
31
 * FIXME:  This should use bit twiddling.
32
 */
29
 */
33
30
34
#include "math.h"
31
#include "math.h"
Lines 54-60 cospil(long double x) Link Here
54
51
55
	ax = fabsl(x);
52
	ax = fabsl(x);
56
53
57
	if (ax < 1) {
54
	if (ax <= 1) {
58
		if (ax < 0.25) {
55
		if (ax < 0.25) {
59
			if (ax < 0x1p-60) {
56
			if (ax < 0x1p-60) {
60
				if ((int)x == 0)
57
				if ((int)x == 0)
Lines 75-89 cospil(long double x) Link Here
75
	}
72
	}
76
73
77
	if (ax < 0x1p112) {
74
	if (ax < 0x1p112) {
78
		xf = floorl(ax);
75
		/* Split x = n + r with 0 <= r < 1. */
79
		ax -= xf;
76
		xf = (ax + 0x1p112L) - 0x1p112L;        /* Integer part */
80
		if (x < 0.5) {
77
		ax -= xf;                               /* Remainder */
81
			if (x < 0.25)
78
		if (ax < 0) {
79
			ax += 1;
80
			xf -= 1;
81
		}
82
83
		if (ax < 0.5) {
84
			if (ax < 0.25)
82
				c = ax == 0 ? 1 : __kernel_cospil(ax);
85
				c = ax == 0 ? 1 : __kernel_cospil(ax);
83
			else
86
			else
84
				c = __kernel_sinpil(0.5 - ax);
87
				c = __kernel_sinpil(0.5 - ax);
85
		} else {
88
		} else {
86
			if (x < 0.75) {
89
			if (ax < 0.75) {
87
				if (ax == 0.5)
90
				if (ax == 0.5)
88
					return (0);
91
					return (0);
89
				c = -__kernel_sinpil(ax - 0.5);
92
				c = -__kernel_sinpil(ax - 0.5);
Lines 91-100 cospil(long double x) Link Here
91
				c = -__kernel_cospil(1 - ax);
94
				c = -__kernel_cospil(1 - ax);
92
		}
95
		}
93
96
94
		if (xf > 0x1p50)
97
		if (xf > 0x1p64)
95
			xf -= 0x1p50;
98
			xf -= 0x1p64;
96
		if (xf > 0x1p30)
99
		if (xf > 0x1p32)
97
			xf -= 0x1p30;
100
			xf -= 0x1p32;
98
		ix = (uint32_t)xf;
101
		ix = (uint32_t)xf;
99
		return (ix & 1 ? -c : c);
102
		return (ix & 1 ? -c : c);
100
	}
103
	}
(-)b/lib/msun/ld128/s_tanpil.c (-10 / +13 lines)
Lines 1-5 Link Here
1
/*-
1
/*-
2
 * Copyright (c) 2017 Steven G. Kargl
2
 * Copyright (c) 2017-2021 Steven G. Kargl
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
Lines 26-34 Link Here
26
26
27
/*
27
/*
28
 * See ../src/s_tanpi.c for implementation details.
28
 * See ../src/s_tanpi.c for implementation details.
29
 *
30
 * FIXME: This has not been compiled nor has it been tested for accuracy.
31
 * FIXME: This should use bit twiddling.
32
 */
29
 */
33
30
34
#include "math.h"
31
#include "math.h"
Lines 75-81 tanpil(long double x) Link Here
75
	long double ax, hi, lo, xf, t;
72
	long double ax, hi, lo, xf, t;
76
	uint32_t ix;
73
	uint32_t ix;
77
74
78
	ax = fabsl(ax);
75
	ax = fabsl(x);
79
76
80
	if (ax < 1) {
77
	if (ax < 1) {
81
		if (ax < 0.5) {
78
		if (ax < 0.5) {
Lines 94-112 tanpil(long double x) Link Here
94
			return ((ax - ax) / (ax - ax));
91
			return ((ax - ax) / (ax - ax));
95
		else
92
		else
96
			t = -__kernel_tanpil(1 - ax);
93
			t = -__kernel_tanpil(1 - ax);
97
		return (copysignl(t, x));
94
		return (x < 0 ? -t : t);
98
	}
95
	}
99
96
100
	if (ix < 0x1p112) {
97
	if (ix < 0x1p112) {
101
		xf = floorl(ax);
98
		/* Split x = n + r with 0 <= r < 1. */
102
		ax -= xf;
99
		xf = (ax + 0x1p112L) - 0x1p112L;        /* Integer part */
100
		ax -= xf;                               /* Remainder */
101
		if (ax < 0) {
102
			ax += 1;
103
			xf -= 1;
104
		}
105
103
		if (ax < 0.5)
106
		if (ax < 0.5)
104
			t = ax == 0 ? 0 : __kernel_tanpil(ax);
107
			t = ax == 0 ? 0 : __kernel_tanpil(ax);
105
		else if (ax == 0.5)
108
		else if (ax == 0.5)
106
			return ((ax - ax) / (ax - ax));
109
			return ((ax - ax) / (ax - ax));
107
		else
110
		else
108
			t = -__kernel_tanpil(1 - ax);
111
			t = -__kernel_tanpil(1 - ax);
109
		return (copysignl(t, x));
112
		return (x < 0 ? -t : t);
110
	}
113
	}
111
114
112
	/* x = +-inf or nan. */
115
	/* x = +-inf or nan. */
Lines 114-120 tanpil(long double x) Link Here
114
		return (vzero / vzero);
117
		return (vzero / vzero);
115
118
116
	/*
119
	/*
117
	 * |x| >= 0x1p53 is always an integer, so return +-0.
120
	 * |x| >= 0x1p112 is always an integer, so return +-0.
118
	 */
121
	 */
119
	return (copysignl(0, x));
122
	return (copysignl(0, x));
120
}
123
}

Return to bug 218514