1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright © 2019 Keith Packard
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above
14  *    copyright notice, this list of conditions and the following
15  *    disclaimer in the documentation and/or other materials provided
16  *    with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  *    contributors may be used to endorse or promote products derived
20  *    from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33  * OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 #include "test.h"
36  one_line_type copysignf_vec[] = {
37 
38 /* copysign(x,±0) = ±x for any x (even a zero or quiet NaN) */
39 {64, 0,123,__LINE__, 0x7ff80000, 0x00000000, 0x7ff80000, 0x00000000, 0x00000000, 0x00000000 },   /* qnan=f(qnan, +0) */
40 {64, 0,123,__LINE__, 0x7ff40000, 0x00000000, 0x7ff40000, 0x00000000, 0x00000000, 0x00000000 },   /* snan=f(snan, +0) */
41 {64, 0,123,__LINE__, 0x7ff00000, 0x00000000, 0x7ff00000, 0x00000000, 0x00000000, 0x00000000 },   /* +inf=f(+inf, +0) */
42 {64, 0,123,__LINE__, 0x7ff00000, 0x00000000, 0xfff00000, 0x00000000, 0x00000000, 0x00000000 },   /* +inf=f(-inf, +0) */
43 {64, 0,123,__LINE__, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },   /* +0=f(+0, +0) */
44 {64, 0,123,__LINE__, 0x00000000, 0x00000000, 0x80000000, 0x00000000, 0x00000000, 0x00000000 },   /* +0=f(-0, +0) */
45 {64, 0,123,__LINE__, 0xfff80000, 0x00000000, 0x7ff80000, 0x00000000, 0x80000000, 0x00000000 },   /* -qnan=f(qnan, -0) */
46 {64, 0,123,__LINE__, 0xfff40000, 0x00000000, 0x7ff40000, 0x00000000, 0x80000000, 0x00000000 },   /* -qnan=f(snan, -0) */
47 {64, 0,123,__LINE__, 0xfff00000, 0x00000000, 0x7ff00000, 0x00000000, 0x80000000, 0x00000000 },   /* -inf=f(+inf, -0) */
48 {64, 0,123,__LINE__, 0xfff00000, 0x00000000, 0xfff00000, 0x00000000, 0x80000000, 0x00000000 },   /* -inf=f(-inf, -0) */
49 {64, 0,123,__LINE__, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x80000000, 0x00000000 },   /* -0=f(+0, -0) */
50 {64, 0,123,__LINE__, 0x80000000, 0x00000000, 0x80000000, 0x00000000, 0x80000000, 0x00000000 },   /* -0=f(-0, -0) */
51 
52 /* copysign(±0, -y) = -0 */
53 {64, 0,123,__LINE__, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0xc0080000, 0x00000000 },   /* -0=f(+0, -3) */
54 {64, 0,123,__LINE__, 0x80000000, 0x00000000, 0x80000000, 0x00000000, 0xc0080000, 0x00000000 },   /* -0=f(-0, -3) */
55 {64, 0,123,__LINE__, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0xc0100000, 0x00000000 },   /* -0=f(+0, -4) */
56 {64, 0,123,__LINE__, 0x80000000, 0x00000000, 0x80000000, 0x00000000, 0xc0100000, 0x00000000 },   /* -0=f(-0, -4) */
57 {64, 0,123,__LINE__, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0xbfe00000, 0x00000000 },   /* -0=f(+0, -0.5) */
58 {64, 0,123,__LINE__, 0x80000000, 0x00000000, 0x80000000, 0x00000000, 0xbfe00000, 0x00000000 },   /* -0=f(-0, -0.5) */
59 
60 /* copysign(±0, +y) = +0 */
61 {64, 0,123,__LINE__, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40080000, 0x00000000 },   /* -0=f(+0, 3) */
62 {64, 0,123,__LINE__, 0x00000000, 0x00000000, 0x80000000, 0x00000000, 0x40080000, 0x00000000 },   /* -0=f(-0, 3) */
63 {64, 0,123,__LINE__, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40100000, 0x00000000 },   /* -0=f(+0, 4) */
64 {64, 0,123,__LINE__, 0x00000000, 0x00000000, 0x80000000, 0x00000000, 0x40100000, 0x00000000 },   /* -0=f(-0, 4) */
65 {64, 0,123,__LINE__, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3fe00000, 0x00000000 },   /* -0=f(+0, 0.5) */
66 {64, 0,123,__LINE__, 0x00000000, 0x00000000, 0x80000000, 0x00000000, 0x3fe00000, 0x00000000 },   /* -0=f(-0, 0.5) */
67 
68 /* copysign(+1,+y)= +1 for any y (even a NaN) */
69 {64, 0,123,__LINE__, 0x3ff00000, 0x00000000, 0x3ff00000, 0x00000000, 0x7ff80000, 0x00000000 },   /* 1=f(1, qnan) */
70 {64, 0,123,__LINE__, 0x3ff00000, 0x00000000, 0x3ff00000, 0x00000000, 0x7ff40000, 0x00000000 },   /* 1=f(1, snan) */
71 {64, 0,123,__LINE__, 0x3ff00000, 0x00000000, 0x3ff00000, 0x00000000, 0x7ff00000, 0x00000000 },   /* 1=f(1, +inf) */
72 {64, 0,123,__LINE__, 0x3ff00000, 0x00000000, 0x3ff00000, 0x00000000, 0x40100000, 0x00000000 },   /* 1=f(1, +4) */
73 {64, 0,123,__LINE__, 0x3ff00000, 0x00000000, 0x3ff00000, 0x00000000, 0x3fe00000, 0x00000000 },   /* 1=f(1, +0.5) */
74 
75 /* copysign(+1,+y)= -1 for any y (even a NaN) */
76 {64, 0,123,__LINE__, 0xbff00000, 0x00000000, 0x3ff00000, 0x00000000, 0xfff80000, 0x00000000 },   /* 1=f(1, -qnan) */
77 {64, 0,123,__LINE__, 0xbff00000, 0x00000000, 0x3ff00000, 0x00000000, 0xfff40000, 0x00000000 },   /* 1=f(1, -snan) */
78 {64, 0,123,__LINE__, 0xbff00000, 0x00000000, 0x3ff00000, 0x00000000, 0xfff00000, 0x00000000 },   /* 1=f(1, -inf) */
79 {64, 0,123,__LINE__, 0xbff00000, 0x00000000, 0x3ff00000, 0x00000000, 0xc0100000, 0x00000000 },   /* 1=f(1, -4) */
80 {64, 0,123,__LINE__, 0xbff00000, 0x00000000, 0x3ff00000, 0x00000000, 0xbfe00000, 0x00000000 },   /* 1=f(1, -0.5) */
81 
82 /* copysign(-1,+y)= +1 for any y (even a NaN) */
83 {64, 0,123,__LINE__, 0x3ff00000, 0x00000000, 0xbff00000, 0x00000000, 0x7ff80000, 0x00000000 },   /* 1=f(1, qnan) */
84 {64, 0,123,__LINE__, 0x3ff00000, 0x00000000, 0xbff00000, 0x00000000, 0x7ff40000, 0x00000000 },   /* 1=f(1, snan) */
85 {64, 0,123,__LINE__, 0x3ff00000, 0x00000000, 0xbff00000, 0x00000000, 0x7ff00000, 0x00000000 },   /* 1=f(1, +inf) */
86 {64, 0,123,__LINE__, 0x3ff00000, 0x00000000, 0xbff00000, 0x00000000, 0x40100000, 0x00000000 },   /* 1=f(1, +4) */
87 {64, 0,123,__LINE__, 0x3ff00000, 0x00000000, 0xbff00000, 0x00000000, 0x3fe00000, 0x00000000 },   /* 1=f(1, +0.5) */
88 
89 /* copysign(+1,+y)= -1 for any y (even a NaN) */
90 {64, 0,123,__LINE__, 0xbff00000, 0x00000000, 0xbff00000, 0x00000000, 0xfff80000, 0x00000000 },   /* 1=f(1, -qnan) */
91 {64, 0,123,__LINE__, 0xbff00000, 0x00000000, 0xbff00000, 0x00000000, 0xfff40000, 0x00000000 },   /* 1=f(1, -snan) */
92 {64, 0,123,__LINE__, 0xbff00000, 0x00000000, 0xbff00000, 0x00000000, 0xfff00000, 0x00000000 },   /* 1=f(1, -inf) */
93 {64, 0,123,__LINE__, 0xbff00000, 0x00000000, 0xbff00000, 0x00000000, 0xc0100000, 0x00000000 },   /* 1=f(1, -4) */
94 {64, 0,123,__LINE__, 0xbff00000, 0x00000000, 0xbff00000, 0x00000000, 0xbfe00000, 0x00000000 },   /* 1=f(1, -0.5) */
95 
96 {0}
97 };
test_copysignf(int m)98 void test_copysignf(int m)   {run_vector_1(m,copysignf_vec,(char *)(copysignf),"copysignf","fff");   }
99