1 | /* $Id: tstRTNoCrt-2.cpp 96338 2022-08-19 15:07:12Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT Testcase - Testcase for the No-CRT math bits.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2008-2022 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #if defined(RT_WITHOUT_NOCRT_WRAPPERS) || !defined(RT_WITHOUT_NOCRT_WRAPPER_ALIASES)
|
---|
32 | # error "Build config error."
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #include <float.h>
|
---|
36 | #include <limits.h>
|
---|
37 | #include <math.h>
|
---|
38 |
|
---|
39 | #define IPRT_NO_CRT_FOR_3RD_PARTY
|
---|
40 | #define IPRT_NOCRT_WITHOUT_CONFLICTING_CONSTANTS /* so we can include both the CRT one and our no-CRT header */
|
---|
41 | #define IPRT_NOCRT_WITHOUT_CONFLICTING_TYPES /* so we can include both the CRT one and our no-CRT header */
|
---|
42 | #include <iprt/nocrt/math.h>
|
---|
43 | #define IPRT_INCLUDED_nocrt_limits_h /* prevent our limits from being included */
|
---|
44 | #include <iprt/nocrt/stdlib.h>
|
---|
45 | #include <iprt/nocrt/fenv.h> /* Need to test fegetround and stuff. */
|
---|
46 |
|
---|
47 | #include <iprt/string.h>
|
---|
48 | #include <iprt/test.h>
|
---|
49 | #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
|
---|
50 | # include <iprt/x86.h>
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | /* Stuff we provide in our math, but UCRT apparently doesn't: */
|
---|
54 | #ifndef M_E
|
---|
55 | # define M_E 2.7182818284590452354 /* e */
|
---|
56 | #endif
|
---|
57 | #ifndef M_LOG2E
|
---|
58 | # define M_LOG2E 1.4426950408889634074 /* log 2e */
|
---|
59 | #endif
|
---|
60 | #ifndef M_LOG10E
|
---|
61 | # define M_LOG10E 0.43429448190325182765 /* log 10e */
|
---|
62 | #endif
|
---|
63 | #ifndef M_LN2
|
---|
64 | # define M_LN2 0.69314718055994530942 /* log e2 */
|
---|
65 | #endif
|
---|
66 | #ifndef M_LN10
|
---|
67 | # define M_LN10 2.30258509299404568402 /* log e10 */
|
---|
68 | #endif
|
---|
69 | #ifndef M_PI
|
---|
70 | # define M_PI 3.14159265358979323846 /* pi */
|
---|
71 | #endif
|
---|
72 | #ifndef M_PI_2
|
---|
73 | # define M_PI_2 1.57079632679489661923 /* pi/2 */
|
---|
74 | #endif
|
---|
75 | #ifndef M_PI_4
|
---|
76 | # define M_PI_4 0.78539816339744830962 /* pi/4 */
|
---|
77 | #endif
|
---|
78 | #ifndef M_1_PI
|
---|
79 | # define M_1_PI 0.31830988618379067154 /* 1/pi */
|
---|
80 | #endif
|
---|
81 | #ifndef M_2_PI
|
---|
82 | # define M_2_PI 0.63661977236758134308 /* 2/pi */
|
---|
83 | #endif
|
---|
84 | #ifndef M_2_SQRTPI
|
---|
85 | # define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
|
---|
86 | #endif
|
---|
87 | #ifndef M_SQRT2
|
---|
88 | # define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
|
---|
89 | #endif
|
---|
90 | #ifndef M_SQRT1_2
|
---|
91 | # define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
|
---|
92 | #endif
|
---|
93 |
|
---|
94 |
|
---|
95 | /*********************************************************************************************************************************
|
---|
96 | * Defined Constants And Macros *
|
---|
97 | *********************************************************************************************************************************/
|
---|
98 | /*
|
---|
99 | * Macros checking i n t e g e r returns.
|
---|
100 | */
|
---|
101 | #define CHECK_INT(a_Expr, a_rcExpect) do { \
|
---|
102 | int const rcActual = (a_Expr); \
|
---|
103 | if (rcActual != (a_rcExpect)) \
|
---|
104 | RTTestFailed(g_hTest, "line %u: %s -> %d, expected %d", __LINE__, #a_Expr, rcActual, (a_rcExpect)); \
|
---|
105 | } while (0)
|
---|
106 |
|
---|
107 | #define CHECK_INT_SAME(a_Fn, a_Args) do { \
|
---|
108 | int const rcNoCrt = RT_NOCRT(a_Fn) a_Args; \
|
---|
109 | int const rcCrt = a_Fn a_Args; \
|
---|
110 | if (rcNoCrt != rcCrt) \
|
---|
111 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %d; CRT => %d", __LINE__, #a_Fn, #a_Args, rcNoCrt, rcCrt); \
|
---|
112 | } while (0)
|
---|
113 |
|
---|
114 |
|
---|
115 | /*
|
---|
116 | * Macros checking l o n g returns.
|
---|
117 | */
|
---|
118 | #define CHECK_LONG(a_Expr, a_rcExpect) do { \
|
---|
119 | long const rcActual = (a_Expr); \
|
---|
120 | long const rcExpect = (a_rcExpect); \
|
---|
121 | if (rcActual != rcExpect) \
|
---|
122 | RTTestFailed(g_hTest, "line %u: %s -> %ld, expected %ld", __LINE__, #a_Expr, rcActual, rcExpect); \
|
---|
123 | } while (0)
|
---|
124 |
|
---|
125 | #define CHECK_LONG_SAME(a_Fn, a_Args) do { \
|
---|
126 | long const rcNoCrt = RT_NOCRT(a_Fn) a_Args; \
|
---|
127 | long const rcCrt = a_Fn a_Args; \
|
---|
128 | if (rcNoCrt != rcCrt) \
|
---|
129 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %ld; CRT => %ld", __LINE__, #a_Fn, #a_Args, rcNoCrt, rcCrt); \
|
---|
130 | } while (0)
|
---|
131 |
|
---|
132 |
|
---|
133 | /*
|
---|
134 | * Macros checking l o n g l o n g returns.
|
---|
135 | */
|
---|
136 | #define CHECK_LLONG(a_Expr, a_rcExpect) do { \
|
---|
137 | long long const rcActual = (a_Expr); \
|
---|
138 | long long const rcExpect = (a_rcExpect); \
|
---|
139 | if (rcActual != rcExpect) \
|
---|
140 | RTTestFailed(g_hTest, "line %u: %s -> %lld, expected %lld", __LINE__, #a_Expr, rcActual, rcExpect); \
|
---|
141 | } while (0)
|
---|
142 |
|
---|
143 | #define CHECK_LLONG_SAME(a_Fn, a_Args) do { \
|
---|
144 | long long const rcNoCrt = RT_NOCRT(a_Fn) a_Args; \
|
---|
145 | long long const rcCrt = a_Fn a_Args; \
|
---|
146 | if (rcNoCrt != rcCrt) \
|
---|
147 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %lld; CRT => %lld", __LINE__, #a_Fn, #a_Args, rcNoCrt, rcCrt); \
|
---|
148 | } while (0)
|
---|
149 |
|
---|
150 |
|
---|
151 | /*
|
---|
152 | * Macros checking l o n g d o u b l e returns.
|
---|
153 | */
|
---|
154 | #ifdef RT_COMPILER_WITH_80BIT_LONG_DOUBLE
|
---|
155 | # define CHECK_LDBL(a_Expr, a_lrdExpect) do { \
|
---|
156 | RTFLOAT80U2 uRet; \
|
---|
157 | uRet.r = (a_Expr); \
|
---|
158 | RTFLOAT80U2 uExpect; \
|
---|
159 | uExpect.r = a_lrdExpect; \
|
---|
160 | if (!RTFLOAT80U_ARE_IDENTICAL(&uRet, &uExpect)) \
|
---|
161 | { \
|
---|
162 | RTStrFormatR80u2(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
163 | RTStrFormatR80u2(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
|
---|
164 | RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
|
---|
165 | __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_lrdExpect); \
|
---|
166 | } \
|
---|
167 | } while (0)
|
---|
168 |
|
---|
169 | # define CHECK_LDBL_SAME(a_Fn, a_Args) do { \
|
---|
170 | RTFLOAT80U2 uNoCrtRet, uCrtRet; \
|
---|
171 | uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
|
---|
172 | uCrtRet.r = a_Fn a_Args; \
|
---|
173 | if (!RTFLOAT80U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
|
---|
174 | { \
|
---|
175 | RTStrFormatR80u2(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
176 | RTStrFormatR80u2(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
177 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
|
---|
178 | __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
|
---|
179 | } \
|
---|
180 | } while (0)
|
---|
181 |
|
---|
182 | # define CHECK_LDBL_APPROX_SAME(a_Fn, a_Args) do { \
|
---|
183 | RTFLOAT80U2 uNoCrtRet, uCrtRet; \
|
---|
184 | uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
|
---|
185 | uCrtRet.r = a_Fn a_Args; \
|
---|
186 | if ( !RTFLOAT80U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
|
---|
187 | && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
|
---|
188 | || RTFLOAT80U_IS_NAN(&uNoCrtRet) \
|
---|
189 | || RTFLOAT80U_IS_NAN(&uCrtRet) ) ) \
|
---|
190 | { \
|
---|
191 | RTStrFormatR80u2(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
192 | RTStrFormatR80u2(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
193 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
|
---|
194 | __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
|
---|
195 | } \
|
---|
196 | } while (0)
|
---|
197 |
|
---|
198 | # define CHECK_LDBL_SAME_RELAXED_NAN(a_Fn, a_Args) do { \
|
---|
199 | RTFLOAT80U2 uNoCrtRet, uCrtRet; \
|
---|
200 | uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
|
---|
201 | uCrtRet.r = a_Fn a_Args; \
|
---|
202 | if ( !RTFLOAT80U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
|
---|
203 | && ( !RTFLOAT80U_IS_NAN(&uNoCrtRet) \
|
---|
204 | || !RTFLOAT80U_IS_NAN(&uCrtRet) ) ) \
|
---|
205 | { \
|
---|
206 | RTStrFormatR80u2(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
207 | RTStrFormatR80u2(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
208 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
|
---|
209 | __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
|
---|
210 | } \
|
---|
211 | } while (0)
|
---|
212 |
|
---|
213 | #elif defined(RT_COMPILER_WITH_128BIT_LONG_DOUBLE)
|
---|
214 | # error todo
|
---|
215 |
|
---|
216 | #else
|
---|
217 | # define CHECK_LDBL(a_Expr, a_lrdExpect) do { \
|
---|
218 | RTFLOAT64U uRet; \
|
---|
219 | uRet.lrd = (a_Expr); \
|
---|
220 | RTFLOAT64U uExpect; \
|
---|
221 | uExpect.lrd = a_lrdExpect; \
|
---|
222 | if (!RTFLOAT64U_ARE_IDENTICAL(&uRet, &uExpect)) \
|
---|
223 | { \
|
---|
224 | RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
225 | RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
|
---|
226 | RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
|
---|
227 | __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_lrdExpect); \
|
---|
228 | } \
|
---|
229 | } while (0)
|
---|
230 |
|
---|
231 | # define CHECK_LDBL_SAME(a_Fn, a_Args) do { \
|
---|
232 | RTFLOAT64U uNoCrtRet, uCrtRet; \
|
---|
233 | uNoCrtRet.lrd = RT_NOCRT(a_Fn) a_Args; \
|
---|
234 | uCrtRet.lrd = a_Fn a_Args; \
|
---|
235 | if (!RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
|
---|
236 | { \
|
---|
237 | RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
238 | RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
239 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
|
---|
240 | __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
|
---|
241 | } \
|
---|
242 | } while (0)
|
---|
243 |
|
---|
244 | # define CHECK_LDBL_APPROX_SAME(a_Fn, a_Args) do { \
|
---|
245 | RTFLOAT64U uNoCrtRet, uCrtRet; \
|
---|
246 | uNoCrtRet.lrd = RT_NOCRT(a_Fn) a_Args; \
|
---|
247 | uCrtRet.lrd = a_Fn a_Args; \
|
---|
248 | if ( !RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
|
---|
249 | && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
|
---|
250 | || RTFLOAT64U_IS_NAN(&uNoCrtRet) \
|
---|
251 | || RTFLOAT64U_IS_NAN(&uCrtRet) ) ) \
|
---|
252 | { \
|
---|
253 | RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
254 | RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
255 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
|
---|
256 | __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
|
---|
257 | } \
|
---|
258 | } while (0)
|
---|
259 |
|
---|
260 | # define CHECK_LDBL_SAME_RELAXED_NAN(a_Fn, a_Args) do { \
|
---|
261 | RTFLOAT64U uNoCrtRet, uCrtRet; \
|
---|
262 | uNoCrtRet.lrd = RT_NOCRT(a_Fn) a_Args; \
|
---|
263 | uCrtRet.lrd = a_Fn a_Args; \
|
---|
264 | if ( !RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
|
---|
265 | && ( !RTFLOAT64U_IS_NAN(&uNoCrtRet) \
|
---|
266 | || !RTFLOAT64U_IS_NAN(&uCrtRet) ) ) \
|
---|
267 | { \
|
---|
268 | RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
269 | RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
270 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
|
---|
271 | __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
|
---|
272 | } \
|
---|
273 | } while (0)
|
---|
274 | #endif
|
---|
275 |
|
---|
276 |
|
---|
277 | /*
|
---|
278 | * Macros checking d o u b l e returns.
|
---|
279 | */
|
---|
280 | #define CHECK_DBL(a_Expr, a_rdExpect) do { \
|
---|
281 | RTFLOAT64U uRet; \
|
---|
282 | uRet.r = (a_Expr); \
|
---|
283 | RTFLOAT64U uExpect; \
|
---|
284 | uExpect.r = a_rdExpect; \
|
---|
285 | if (!RTFLOAT64U_ARE_IDENTICAL(&uRet, &uExpect)) \
|
---|
286 | { \
|
---|
287 | RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
288 | RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
|
---|
289 | RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
|
---|
290 | __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_rdExpect); \
|
---|
291 | } \
|
---|
292 | } while (0)
|
---|
293 |
|
---|
294 | #define CHECK_DBL_SAME(a_Fn, a_Args) do { \
|
---|
295 | RTFLOAT64U uNoCrtRet, uCrtRet; \
|
---|
296 | uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
|
---|
297 | uCrtRet.r = a_Fn a_Args; \
|
---|
298 | if (!RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
|
---|
299 | { \
|
---|
300 | RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
301 | RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
302 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
|
---|
303 | __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
|
---|
304 | } \
|
---|
305 | } while (0)
|
---|
306 |
|
---|
307 | #define CHECK_DBL_APPROX_SAME(a_Fn, a_Args, a_cMaxDelta) do { \
|
---|
308 | RTFLOAT64U uNoCrtRet, uCrtRet; \
|
---|
309 | uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
|
---|
310 | uCrtRet.r = a_Fn a_Args; \
|
---|
311 | if ( !RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
|
---|
312 | && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > (a_cMaxDelta) \
|
---|
313 | || RTFLOAT64U_IS_NAN(&uNoCrtRet) \
|
---|
314 | || RTFLOAT64U_IS_NAN(&uCrtRet) ) ) \
|
---|
315 | { \
|
---|
316 | RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
317 | RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
318 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s (max delta %u)", \
|
---|
319 | __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1], (a_cMaxDelta)); \
|
---|
320 | } \
|
---|
321 | } while (0)
|
---|
322 |
|
---|
323 | #define CHECK_DBL_RANGE(a_Expr, a_rdExpect, a_rdPlusMin) do { \
|
---|
324 | RTFLOAT64U uRet; \
|
---|
325 | uRet.r = a_Expr; \
|
---|
326 | RTFLOAT64U uExpectMin; \
|
---|
327 | uExpectMin.r = (a_rdExpect) - (a_rdPlusMin); \
|
---|
328 | RTFLOAT64U uExpectMax; \
|
---|
329 | uExpectMax.r = (a_rdExpect) + (a_rdPlusMin); \
|
---|
330 | if ( !(RTFLOAT64U_IS_NORMAL(&uRet) || RTFLOAT64U_IS_ZERO(&uRet))\
|
---|
331 | || uRet.r < uExpectMin.r \
|
---|
332 | || uRet.r > uExpectMax.r ) \
|
---|
333 | { \
|
---|
334 | RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
335 | RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[1]), &uExpectMin, 0, 0, RTSTR_F_SPECIAL); \
|
---|
336 | RTStrFormatR64(g_szFloat[2], sizeof(g_szFloat[2]), &uExpectMax, 0, 0, RTSTR_F_SPECIAL); \
|
---|
337 | RTTestFailed(g_hTest, "line %u: %s -> %s, expected [%s,%s] (%s +/- %s)", \
|
---|
338 | __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], g_szFloat[2], #a_rdExpect, #a_rdPlusMin); \
|
---|
339 | } \
|
---|
340 | } while (0)
|
---|
341 |
|
---|
342 | #define CHECK_DBL_SAME_RELAXED_NAN(a_Fn, a_Args) do { \
|
---|
343 | RTFLOAT64U uNoCrtRet, uCrtRet; \
|
---|
344 | uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
|
---|
345 | uCrtRet.r = a_Fn a_Args; \
|
---|
346 | if ( !RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
|
---|
347 | && ( !RTFLOAT64U_IS_NAN(&uNoCrtRet) \
|
---|
348 | || !RTFLOAT64U_IS_NAN(&uCrtRet) ) ) \
|
---|
349 | { \
|
---|
350 | RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
351 | RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
352 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
|
---|
353 | __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
|
---|
354 | } \
|
---|
355 | } while (0)
|
---|
356 |
|
---|
357 | /*
|
---|
358 | * Macros checking f l o a t returns.
|
---|
359 | */
|
---|
360 | #define CHECK_FLT(a_Expr, a_rExpect) do { \
|
---|
361 | RTFLOAT32U uRet; \
|
---|
362 | uRet.r = (a_Expr); \
|
---|
363 | RTFLOAT32U uExpect; \
|
---|
364 | uExpect.r = a_rExpect; \
|
---|
365 | if (!RTFLOAT32U_ARE_IDENTICAL(&uRet, &uExpect)) \
|
---|
366 | { \
|
---|
367 | RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
368 | RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
|
---|
369 | RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
|
---|
370 | __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_rExpect); \
|
---|
371 | } \
|
---|
372 | } while (0)
|
---|
373 |
|
---|
374 | #define CHECK_FLT_SAME(a_Fn, a_Args) do { \
|
---|
375 | RTFLOAT32U uNoCrtRet, uCrtRet; \
|
---|
376 | uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
|
---|
377 | uCrtRet.r = a_Fn a_Args; \
|
---|
378 | if (!RTFLOAT32U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
|
---|
379 | { \
|
---|
380 | RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
381 | RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
382 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
|
---|
383 | __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
|
---|
384 | } \
|
---|
385 | } while (0)
|
---|
386 |
|
---|
387 | #define CHECK_FLT_APPROX_SAME(a_Fn, a_Args, a_cMaxDelta) do { \
|
---|
388 | RTFLOAT32U uNoCrtRet, uCrtRet; \
|
---|
389 | uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
|
---|
390 | uCrtRet.r = a_Fn a_Args; \
|
---|
391 | if ( !RTFLOAT32U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
|
---|
392 | && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > (a_cMaxDelta) \
|
---|
393 | || RTFLOAT32U_IS_NAN(&uNoCrtRet) \
|
---|
394 | || RTFLOAT32U_IS_NAN(&uCrtRet) ) ) \
|
---|
395 | { \
|
---|
396 | RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
397 | RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
398 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s (max delta %u)", \
|
---|
399 | __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1], a_cMaxDelta); \
|
---|
400 | } \
|
---|
401 | } while (0)
|
---|
402 |
|
---|
403 | #define CHECK_FLT_RANGE(a_Expr, a_rfExpect, a_rfPlusMin) do { \
|
---|
404 | RTFLOAT32U uRet; \
|
---|
405 | uRet.r = a_Expr; \
|
---|
406 | RTFLOAT32U uExpectMin; \
|
---|
407 | uExpectMin.r = (a_rfExpect) - (a_rfPlusMin); \
|
---|
408 | RTFLOAT32U uExpectMax; \
|
---|
409 | uExpectMax.r = (a_rfExpect) + (a_rfPlusMin); \
|
---|
410 | if ( !(RTFLOAT32U_IS_NORMAL(&uRet) || RTFLOAT32U_IS_ZERO(&uRet))\
|
---|
411 | || uRet.r < uExpectMin.r \
|
---|
412 | || uRet.r > uExpectMax.r ) \
|
---|
413 | { \
|
---|
414 | RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
415 | RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[1]), &uExpectMin, 0, 0, RTSTR_F_SPECIAL); \
|
---|
416 | RTStrFormatR32(g_szFloat[2], sizeof(g_szFloat[2]), &uExpectMax, 0, 0, RTSTR_F_SPECIAL); \
|
---|
417 | RTTestFailed(g_hTest, "line %u: %s -> %s, expected [%s,%s] (%s +/- %s)", \
|
---|
418 | __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], g_szFloat[2], #a_rfExpect, #a_rfPlusMin); \
|
---|
419 | } \
|
---|
420 | } while (0)
|
---|
421 |
|
---|
422 | #define CHECK_FLT_SAME_RELAXED_NAN(a_Fn, a_Args) do { \
|
---|
423 | RTFLOAT32U uNoCrtRet, uCrtRet; \
|
---|
424 | uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
|
---|
425 | uCrtRet.r = a_Fn a_Args; \
|
---|
426 | if ( !RTFLOAT32U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
|
---|
427 | && ( !RTFLOAT32U_IS_NAN(&uNoCrtRet) \
|
---|
428 | || !RTFLOAT32U_IS_NAN(&uCrtRet) ) ) \
|
---|
429 | { \
|
---|
430 | RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
431 | RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
|
---|
432 | RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
|
---|
433 | __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
|
---|
434 | } \
|
---|
435 | } while (0)
|
---|
436 |
|
---|
437 |
|
---|
438 |
|
---|
439 | #define CHECK_XCPT(a_InnerTestExpr, a_fXcptMask, a_fXcptExpect) do { \
|
---|
440 | RT_NOCRT(feclearexcept(RT_NOCRT_FE_ALL_EXCEPT)); \
|
---|
441 | a_InnerTestExpr; \
|
---|
442 | int const fXcpt = RT_NOCRT(fetestexcept)(RT_NOCRT_FE_ALL_EXCEPT); \
|
---|
443 | if ((fXcpt & (a_fXcptMask)) != (a_fXcptExpect)) \
|
---|
444 | RTTestFailed(g_hTest, "line %u: %s -^-> %#x, expected %#x (%s)", \
|
---|
445 | __LINE__, #a_InnerTestExpr, fXcpt, (a_fXcptExpect), #a_fXcptExpect); \
|
---|
446 | RT_NOCRT(feclearexcept(RT_NOCRT_FE_ALL_EXCEPT)); \
|
---|
447 | } while (0)
|
---|
448 |
|
---|
449 |
|
---|
450 | /*********************************************************************************************************************************
|
---|
451 | * Global Variables *
|
---|
452 | *********************************************************************************************************************************/
|
---|
453 | RTTEST g_hTest;
|
---|
454 | char g_szFloat[4][128];
|
---|
455 |
|
---|
456 |
|
---|
457 | #ifdef _MSC_VER
|
---|
458 | # pragma fenv_access(on)
|
---|
459 | #endif
|
---|
460 |
|
---|
461 |
|
---|
462 | void testAbs()
|
---|
463 | {
|
---|
464 | RTTestSub(g_hTest, "abs,labs,llabs");
|
---|
465 | CHECK_INT(RT_NOCRT(abs)(1), 1);
|
---|
466 | CHECK_INT(RT_NOCRT(abs)(-1), 1);
|
---|
467 | CHECK_INT(RT_NOCRT(abs)(9685), 9685);
|
---|
468 | CHECK_INT(RT_NOCRT(abs)(-9685), 9685);
|
---|
469 | CHECK_INT(RT_NOCRT(abs)(589685), 589685);
|
---|
470 | CHECK_INT(RT_NOCRT(abs)(-589685), 589685);
|
---|
471 | CHECK_INT(RT_NOCRT(abs)(INT_MAX), INT_MAX);
|
---|
472 | CHECK_INT(RT_NOCRT(abs)(INT_MIN + 1), INT_MAX);
|
---|
473 | CHECK_INT(RT_NOCRT(abs)(INT_MIN), INT_MIN); /* oddity */
|
---|
474 | CHECK_INT_SAME(abs,(INT_MIN));
|
---|
475 | CHECK_INT_SAME(abs,(INT_MAX));
|
---|
476 |
|
---|
477 | CHECK_LONG(RT_NOCRT(labs)(1), 1);
|
---|
478 | CHECK_LONG(RT_NOCRT(labs)(-1), 1);
|
---|
479 | CHECK_LONG(RT_NOCRT(labs)(9685), 9685);
|
---|
480 | CHECK_LONG(RT_NOCRT(labs)(-9685), 9685);
|
---|
481 | CHECK_LONG(RT_NOCRT(labs)(589685), 589685);
|
---|
482 | CHECK_LONG(RT_NOCRT(labs)(-589685), 589685);
|
---|
483 | CHECK_LONG(RT_NOCRT(labs)(LONG_MAX), LONG_MAX);
|
---|
484 | CHECK_LONG(RT_NOCRT(labs)(LONG_MIN + 1), LONG_MAX);
|
---|
485 | CHECK_LONG(RT_NOCRT(labs)(LONG_MIN), LONG_MIN); /* oddity */
|
---|
486 | CHECK_LONG_SAME(labs,(LONG_MIN));
|
---|
487 | CHECK_LONG_SAME(labs,(LONG_MAX));
|
---|
488 |
|
---|
489 | CHECK_LONG(RT_NOCRT(llabs)(1), 1);
|
---|
490 | CHECK_LONG(RT_NOCRT(llabs)(-1), 1);
|
---|
491 | CHECK_LONG(RT_NOCRT(llabs)(9685), 9685);
|
---|
492 | CHECK_LONG(RT_NOCRT(llabs)(-9685), 9685);
|
---|
493 | CHECK_LONG(RT_NOCRT(llabs)(589685), 589685);
|
---|
494 | CHECK_LONG(RT_NOCRT(llabs)(-589685), 589685);
|
---|
495 | CHECK_LONG(RT_NOCRT(llabs)(LONG_MAX), LONG_MAX);
|
---|
496 | CHECK_LONG(RT_NOCRT(llabs)(LONG_MIN + 1), LONG_MAX);
|
---|
497 | CHECK_LONG(RT_NOCRT(llabs)(LONG_MIN), LONG_MIN); /* oddity */
|
---|
498 | CHECK_LONG_SAME(llabs,(LONG_MIN));
|
---|
499 | CHECK_LONG_SAME(llabs,(LONG_MAX));
|
---|
500 | }
|
---|
501 |
|
---|
502 |
|
---|
503 | void testFAbs()
|
---|
504 | {
|
---|
505 | RTTestSub(g_hTest, "fabs[fl]");
|
---|
506 |
|
---|
507 | CHECK_DBL(RT_NOCRT(fabs)( +0.0), +0.0);
|
---|
508 | CHECK_DBL(RT_NOCRT(fabs)( -0.0), +0.0);
|
---|
509 | CHECK_DBL(RT_NOCRT(fabs)( -42.5), +42.5);
|
---|
510 | CHECK_DBL(RT_NOCRT(fabs)( +42.5), +42.5);
|
---|
511 | CHECK_DBL(RT_NOCRT(fabs)(+1234.60958634e+20), +1234.60958634e+20);
|
---|
512 | CHECK_DBL(RT_NOCRT(fabs)(-1234.60958634e+20), +1234.60958634e+20);
|
---|
513 | CHECK_DBL(RT_NOCRT(fabs)( +2.1984e-310), +2.1984e-310); /* subnormal */
|
---|
514 | CHECK_DBL(RT_NOCRT(fabs)( -2.1984e-310), +2.1984e-310); /* subnormal */
|
---|
515 | CHECK_DBL(RT_NOCRT(fabs)(-INFINITY), +INFINITY);
|
---|
516 | CHECK_DBL(RT_NOCRT(fabs)(+INFINITY), +INFINITY);
|
---|
517 | CHECK_DBL(RT_NOCRT(fabs)(RTStrNanDouble(NULL, true)), RTStrNanDouble(NULL, true));
|
---|
518 | CHECK_DBL(RT_NOCRT(fabs)(RTStrNanDouble("s", false)), RTStrNanDouble("s", true));
|
---|
519 | CHECK_DBL_SAME(fabs,( -0.0));
|
---|
520 | CHECK_DBL_SAME(fabs,( +0.0));
|
---|
521 | CHECK_DBL_SAME(fabs,( +22.5));
|
---|
522 | CHECK_DBL_SAME(fabs,( -22.5));
|
---|
523 | CHECK_DBL_SAME(fabs,( +2.1984e-310)); /* subnormal */
|
---|
524 | CHECK_DBL_SAME(fabs,( -2.1984e-310)); /* subnormal */
|
---|
525 | CHECK_DBL_SAME(fabs,(+1234.60958634e+20));
|
---|
526 | CHECK_DBL_SAME(fabs,(-1234.60958634e+20));
|
---|
527 | CHECK_DBL_SAME(fabs,(-INFINITY));
|
---|
528 | CHECK_DBL_SAME(fabs,(+INFINITY));
|
---|
529 | CHECK_DBL_SAME(fabs,(RTStrNanDouble(NULL, true)));
|
---|
530 | CHECK_DBL_SAME(fabs,(RTStrNanDouble("s", false)));
|
---|
531 |
|
---|
532 | CHECK_FLT(RT_NOCRT(fabsf)( +0.0f), +0.0f);
|
---|
533 | CHECK_FLT(RT_NOCRT(fabsf)( -0.0f), +0.0f);
|
---|
534 | CHECK_FLT(RT_NOCRT(fabsf)( -42.5f), +42.5f);
|
---|
535 | CHECK_FLT(RT_NOCRT(fabsf)( +42.5f), +42.5f);
|
---|
536 | CHECK_FLT(RT_NOCRT(fabsf)(+1234.60958634e+20f), +1234.60958634e+20f);
|
---|
537 | CHECK_FLT(RT_NOCRT(fabsf)(-1234.60958634e+20f), +1234.60958634e+20f);
|
---|
538 | CHECK_FLT(RT_NOCRT(fabsf)( +2.1984e-310f), +2.1984e-310f); /* subnormal */
|
---|
539 | CHECK_FLT(RT_NOCRT(fabsf)( -2.1984e-310f), +2.1984e-310f); /* subnormal */
|
---|
540 | CHECK_FLT(RT_NOCRT(fabsf)(-INFINITY), +INFINITY);
|
---|
541 | CHECK_FLT(RT_NOCRT(fabsf)(+INFINITY), +INFINITY);
|
---|
542 | CHECK_FLT(RT_NOCRT(fabsf)(RTStrNanFloat(NULL, true)), RTStrNanFloat(NULL, true));
|
---|
543 | CHECK_FLT(RT_NOCRT(fabsf)(RTStrNanFloat("s", false)), RTStrNanFloat("s", true));
|
---|
544 | CHECK_FLT_SAME(fabsf,( -0.0f));
|
---|
545 | CHECK_FLT_SAME(fabsf,( +0.0f));
|
---|
546 | CHECK_FLT_SAME(fabsf,( +22.5f));
|
---|
547 | CHECK_FLT_SAME(fabsf,( -22.5f));
|
---|
548 | CHECK_FLT_SAME(fabsf,( +2.1984e-310f)); /* subnormal */
|
---|
549 | CHECK_FLT_SAME(fabsf,( -2.1984e-310f)); /* subnormal */
|
---|
550 | CHECK_FLT_SAME(fabsf,(+1234.60958634e+20f));
|
---|
551 | CHECK_FLT_SAME(fabsf,(-1234.60958634e+20f));
|
---|
552 | CHECK_FLT_SAME(fabsf,(-INFINITY));
|
---|
553 | CHECK_FLT_SAME(fabsf,(+INFINITY));
|
---|
554 | CHECK_FLT_SAME(fabsf,(RTStrNanFloat(NULL, true)));
|
---|
555 | #if 0 /* UCRT on windows converts this to a quiet NaN, so skip it. */
|
---|
556 | CHECK_FLT_SAME(fabsf,(RTStrNanFloat("s", false)));
|
---|
557 | #endif
|
---|
558 | }
|
---|
559 |
|
---|
560 |
|
---|
561 | void testCopySign()
|
---|
562 | {
|
---|
563 | RTTestSub(g_hTest, "copysign[fl]");
|
---|
564 |
|
---|
565 | CHECK_DBL(RT_NOCRT(copysign)(1.0, 2.0), 1.0);
|
---|
566 | CHECK_DBL(RT_NOCRT(copysign)(-1.0, 2.0), 1.0);
|
---|
567 | CHECK_DBL(RT_NOCRT(copysign)(-1.0, -2.0), -1.0);
|
---|
568 | CHECK_DBL(RT_NOCRT(copysign)(1.0, -2.0), -1.0);
|
---|
569 | CHECK_DBL(RT_NOCRT(copysign)(42.24, -INFINITY), -42.24);
|
---|
570 | CHECK_DBL(RT_NOCRT(copysign)(-42.24, +INFINITY), +42.24);
|
---|
571 | CHECK_DBL(RT_NOCRT(copysign)(-999888777.666, RTStrNanDouble(NULL, true)), +999888777.666);
|
---|
572 | CHECK_DBL(RT_NOCRT(copysign)(-999888777.666, RTStrNanDouble("sig", true)), +999888777.666);
|
---|
573 | CHECK_DBL(RT_NOCRT(copysign)(+999888777.666, RTStrNanDouble(NULL, false)), -999888777.666);
|
---|
574 | CHECK_DBL_SAME(copysign,(1.0, 2.0));
|
---|
575 | CHECK_DBL_SAME(copysign,(-1.0, 2.0));
|
---|
576 | CHECK_DBL_SAME(copysign,(-1.0, -2.0));
|
---|
577 | CHECK_DBL_SAME(copysign,(1.0, -2.0));
|
---|
578 | CHECK_DBL_SAME(copysign,(42.24, -INFINITY));
|
---|
579 | CHECK_DBL_SAME(copysign,(-42.24, +INFINITY));
|
---|
580 | CHECK_DBL_SAME(copysign,(-999888777.666, RTStrNanDouble(NULL, true)));
|
---|
581 | CHECK_DBL_SAME(copysign,(+999888777.666, RTStrNanDouble(NULL, false)));
|
---|
582 | CHECK_DBL_SAME(copysign,(+999888777.666, RTStrNanDouble("sig", false)));
|
---|
583 |
|
---|
584 | CHECK_FLT(RT_NOCRT(copysignf)(1.0f, 2.0f), 1.0f);
|
---|
585 | CHECK_FLT(RT_NOCRT(copysignf)(-1.0f, 2.0f), 1.0f);
|
---|
586 | CHECK_FLT(RT_NOCRT(copysignf)(-1.0f, -2.0f), -1.0f);
|
---|
587 | CHECK_FLT(RT_NOCRT(copysignf)(1.0f, -2.0f), -1.0f);
|
---|
588 | CHECK_FLT(RT_NOCRT(copysignf)(42.24f, -INFINITY), -42.24f);
|
---|
589 | CHECK_FLT(RT_NOCRT(copysignf)(-42.24f, +INFINITY), +42.24f);
|
---|
590 | CHECK_FLT(RT_NOCRT(copysignf)(-999888777.666f, RTStrNanFloat(NULL, true)), +999888777.666f);
|
---|
591 | CHECK_FLT(RT_NOCRT(copysignf)(+999888777.666f, RTStrNanFloat(NULL, false)), -999888777.666f);
|
---|
592 | CHECK_FLT_SAME(copysignf,(1.0f, 2.0f));
|
---|
593 | CHECK_FLT_SAME(copysignf,(-3.0f, 2.0f));
|
---|
594 | CHECK_FLT_SAME(copysignf,(-5.0e3f, -2.0f));
|
---|
595 | CHECK_FLT_SAME(copysignf,(6.0e-3f, -2.0f));
|
---|
596 | CHECK_FLT_SAME(copysignf,(434.24f, -INFINITY));
|
---|
597 | CHECK_FLT_SAME(copysignf,(-42.24f, +INFINITY));
|
---|
598 | CHECK_FLT_SAME(copysignf,(-39480.6e+33f, RTStrNanFloat(NULL, true)));
|
---|
599 | CHECK_FLT_SAME(copysignf,(+39480.6e-32f, RTStrNanFloat(NULL, false)));
|
---|
600 |
|
---|
601 | CHECK_LDBL(RT_NOCRT(copysignl)(1.0L, 2.0L), 1.0L);
|
---|
602 | CHECK_LDBL(RT_NOCRT(copysignl)(-1.0L, 2.0L), 1.0L);
|
---|
603 | CHECK_LDBL(RT_NOCRT(copysignl)(-1.0L, -2.0L), -1.0L);
|
---|
604 | CHECK_LDBL(RT_NOCRT(copysignl)(1.0L, -2.0L), -1.0L);
|
---|
605 | CHECK_LDBL(RT_NOCRT(copysignl)(42.24L, -INFINITY), -42.24L);
|
---|
606 | CHECK_LDBL(RT_NOCRT(copysignl)(-42.24L, +INFINITY), +42.24L);
|
---|
607 | CHECK_LDBL(RT_NOCRT(copysignl)(-999888777.666L, RTStrNanLongDouble(NULL, true)), +999888777.666L);
|
---|
608 | CHECK_LDBL(RT_NOCRT(copysignl)(+999888777.666L, RTStrNanLongDouble("2343f_sig", false)), -999888777.666L);
|
---|
609 | CHECK_LDBL_SAME(copysignl,(1.0L, 2.0L));
|
---|
610 | CHECK_LDBL_SAME(copysignl,(-3.0L, 2.0L));
|
---|
611 | CHECK_LDBL_SAME(copysignl,(-5.0e3L, -2.0L));
|
---|
612 | CHECK_LDBL_SAME(copysignl,(6.0e-3L, -2.0L));
|
---|
613 | CHECK_LDBL_SAME(copysignl,(434.24L, -INFINITY));
|
---|
614 | CHECK_LDBL_SAME(copysignl,(-42.24L, +INFINITY));
|
---|
615 | CHECK_LDBL_SAME(copysignl,(-39480.6e+33L, RTStrNanLongDouble("8888_s", true)));
|
---|
616 | CHECK_LDBL_SAME(copysignl,(+39480.6e-32L, RTStrNanLongDouble(NULL, false)));
|
---|
617 | }
|
---|
618 |
|
---|
619 |
|
---|
620 | void testFmax()
|
---|
621 | {
|
---|
622 | RTTestSub(g_hTest, "fmax[fl]");
|
---|
623 |
|
---|
624 | CHECK_DBL(RT_NOCRT(fmax)( 1.0, 1.0), 1.0);
|
---|
625 | CHECK_DBL(RT_NOCRT(fmax)( 4.0, 2.0), 4.0);
|
---|
626 | CHECK_DBL(RT_NOCRT(fmax)( 2.0, 4.0), 4.0);
|
---|
627 | CHECK_DBL(RT_NOCRT(fmax)(-2.0, -4.0), -2.0);
|
---|
628 | CHECK_DBL(RT_NOCRT(fmax)(-2.0, -4.0e-10), -4.0e-10);
|
---|
629 | CHECK_DBL(RT_NOCRT(fmax)(+INFINITY, +INFINITY), +INFINITY);
|
---|
630 | CHECK_DBL(RT_NOCRT(fmax)(-INFINITY, -INFINITY), -INFINITY);
|
---|
631 | CHECK_DBL(RT_NOCRT(fmax)(+INFINITY, -INFINITY), +INFINITY);
|
---|
632 | CHECK_DBL(RT_NOCRT(fmax)(-INFINITY, +INFINITY), +INFINITY);
|
---|
633 | CHECK_DBL_SAME(fmax, ( 99.99, 99.87));
|
---|
634 | CHECK_DBL_SAME(fmax, ( -99.99, -99.87));
|
---|
635 | CHECK_DBL_SAME(fmax, (-987.453, 34599.87));
|
---|
636 | CHECK_DBL_SAME(fmax, (34599.87, -987.453));
|
---|
637 | CHECK_DBL_SAME(fmax, ( +0.0, -0.0));
|
---|
638 | CHECK_DBL_SAME(fmax, ( -0.0, +0.0));
|
---|
639 | CHECK_DBL_SAME(fmax, ( -0.0, -0.0));
|
---|
640 | CHECK_DBL_SAME(fmax, (+INFINITY, +INFINITY));
|
---|
641 | CHECK_DBL_SAME(fmax, (-INFINITY, -INFINITY));
|
---|
642 | CHECK_DBL_SAME(fmax, (+INFINITY, -INFINITY));
|
---|
643 | CHECK_DBL_SAME(fmax, (-INFINITY, +INFINITY));
|
---|
644 | CHECK_DBL_SAME(fmax, (RTStrNanDouble(NULL, true), -42.4242424242e222));
|
---|
645 | CHECK_DBL_SAME(fmax, (RTStrNanDouble(NULL, false), -42.4242424242e222));
|
---|
646 | CHECK_DBL_SAME(fmax, (-42.4242424242e-222, RTStrNanDouble(NULL, true)));
|
---|
647 | CHECK_DBL_SAME(fmax, (-42.4242424242e-222, RTStrNanDouble(NULL, false)));
|
---|
648 | CHECK_DBL_SAME(fmax, (RTStrNanDouble("2", false), RTStrNanDouble(NULL, false)));
|
---|
649 | CHECK_DBL_SAME(fmax, (RTStrNanDouble("3", true), RTStrNanDouble(NULL, false)));
|
---|
650 | CHECK_DBL_SAME(fmax, (RTStrNanDouble("4sig", true), RTStrNanDouble(NULL, false)));
|
---|
651 |
|
---|
652 | CHECK_FLT(RT_NOCRT(fmaxf)( 1.0f, 1.0f), 1.0f);
|
---|
653 | CHECK_FLT(RT_NOCRT(fmaxf)( 4.0f, 2.0f), 4.0f);
|
---|
654 | CHECK_FLT(RT_NOCRT(fmaxf)( 2.0f, 4.0f), 4.0f);
|
---|
655 | CHECK_FLT(RT_NOCRT(fmaxf)(-2.0f, -4.0f), -2.0f);
|
---|
656 | CHECK_FLT(RT_NOCRT(fmaxf)(-2.0f, -4.0e-10f), -4.0e-10f);
|
---|
657 | CHECK_FLT(RT_NOCRT(fmaxf)(+INFINITY, +INFINITY), +INFINITY);
|
---|
658 | CHECK_FLT(RT_NOCRT(fmaxf)(-INFINITY, -INFINITY), -INFINITY);
|
---|
659 | CHECK_FLT(RT_NOCRT(fmaxf)(+INFINITY, -INFINITY), +INFINITY);
|
---|
660 | CHECK_FLT(RT_NOCRT(fmaxf)(-INFINITY, +INFINITY), +INFINITY);
|
---|
661 | CHECK_FLT_SAME(fmaxf, ( 99.99f, 99.87f));
|
---|
662 | CHECK_FLT_SAME(fmaxf, ( -99.99f, -99.87f));
|
---|
663 | CHECK_FLT_SAME(fmaxf, (-987.453f, 34599.87f));
|
---|
664 | CHECK_FLT_SAME(fmaxf, (34599.87f, -987.453f));
|
---|
665 | CHECK_FLT_SAME(fmaxf, ( +0.0f, -0.0f));
|
---|
666 | CHECK_FLT_SAME(fmaxf, ( -0.0f, +0.0f));
|
---|
667 | CHECK_FLT_SAME(fmaxf, ( -0.0f, -0.0f));
|
---|
668 | CHECK_FLT_SAME(fmaxf, (+INFINITY, +INFINITY));
|
---|
669 | CHECK_FLT_SAME(fmaxf, (-INFINITY, -INFINITY));
|
---|
670 | CHECK_FLT_SAME(fmaxf, (+INFINITY, -INFINITY));
|
---|
671 | CHECK_FLT_SAME(fmaxf, (-INFINITY, +INFINITY));
|
---|
672 | CHECK_FLT_SAME(fmaxf, (RTStrNanFloat(NULL, true), -42.4242424242e22f));
|
---|
673 | CHECK_FLT_SAME(fmaxf, (RTStrNanFloat(NULL, false), -42.4242424242e22f));
|
---|
674 | CHECK_FLT_SAME(fmaxf, (-42.42424242e-22f, RTStrNanFloat(NULL, true)));
|
---|
675 | CHECK_FLT_SAME(fmaxf, (-42.42424242e-22f, RTStrNanFloat(NULL, false)));
|
---|
676 | CHECK_FLT_SAME(fmaxf, (RTStrNanFloat("2", false), RTStrNanFloat(NULL, false)));
|
---|
677 | CHECK_FLT_SAME(fmaxf, (RTStrNanFloat("3", true), RTStrNanFloat(NULL, false)));
|
---|
678 | CHECK_FLT_SAME(fmaxf, (RTStrNanFloat("4sig", true), RTStrNanFloat(NULL, false)));
|
---|
679 |
|
---|
680 | CHECK_LDBL(RT_NOCRT(fmaxl)( 1.0L, 1.0L), 1.0L);
|
---|
681 | CHECK_LDBL(RT_NOCRT(fmaxl)( 4.0L, 2.0L), 4.0L);
|
---|
682 | CHECK_LDBL(RT_NOCRT(fmaxl)( 2.0L, 4.0L), 4.0L);
|
---|
683 | CHECK_LDBL(RT_NOCRT(fmaxl)(-2.0L, -4.0L), -2.0L);
|
---|
684 | CHECK_LDBL(RT_NOCRT(fmaxl)(-2.0L, -4.0e-10L), -4.0e-10L);
|
---|
685 | CHECK_LDBL(RT_NOCRT(fmaxl)(+INFINITY, +INFINITY), +INFINITY);
|
---|
686 | CHECK_LDBL(RT_NOCRT(fmaxl)(-INFINITY, -INFINITY), -INFINITY);
|
---|
687 | CHECK_LDBL(RT_NOCRT(fmaxl)(+INFINITY, -INFINITY), +INFINITY);
|
---|
688 | CHECK_LDBL(RT_NOCRT(fmaxl)(-INFINITY, +INFINITY), +INFINITY);
|
---|
689 | CHECK_LDBL_SAME(fmaxl, ( 99.99L, 99.87L));
|
---|
690 | CHECK_LDBL_SAME(fmaxl, ( -99.99L, -99.87L));
|
---|
691 | CHECK_LDBL_SAME(fmaxl, (-987.453L, 34599.87L));
|
---|
692 | CHECK_LDBL_SAME(fmaxl, (34599.87L, -987.453L));
|
---|
693 | CHECK_LDBL_SAME(fmaxl, ( +0.0L, -0.0L));
|
---|
694 | CHECK_LDBL_SAME(fmaxl, ( -0.0L, +0.0L));
|
---|
695 | CHECK_LDBL_SAME(fmaxl, ( -0.0L, -0.0L));
|
---|
696 | CHECK_LDBL_SAME(fmaxl, (+INFINITY, +INFINITY));
|
---|
697 | CHECK_LDBL_SAME(fmaxl, (-INFINITY, -INFINITY));
|
---|
698 | CHECK_LDBL_SAME(fmaxl, (+INFINITY, -INFINITY));
|
---|
699 | CHECK_LDBL_SAME(fmaxl, (-INFINITY, +INFINITY));
|
---|
700 | CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble(NULL, true), -42.4242424242e222L));
|
---|
701 | CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble(NULL, false), -42.4242424242e222L));
|
---|
702 | CHECK_LDBL_SAME(fmaxl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, true)));
|
---|
703 | CHECK_LDBL_SAME(fmaxl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, false)));
|
---|
704 | CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble("2", false), RTStrNanLongDouble(NULL, false)));
|
---|
705 | CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble("3", true), RTStrNanLongDouble(NULL, false)));
|
---|
706 | CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble("4sig", true), RTStrNanLongDouble(NULL, false)));
|
---|
707 | }
|
---|
708 |
|
---|
709 |
|
---|
710 | void testFmin()
|
---|
711 | {
|
---|
712 | RTTestSub(g_hTest, "fmin[fl]");
|
---|
713 |
|
---|
714 | CHECK_DBL(RT_NOCRT(fmin)( 1.0, 1.0), 1.0);
|
---|
715 | CHECK_DBL(RT_NOCRT(fmin)( 4.0, 2.0), 2.0);
|
---|
716 | CHECK_DBL(RT_NOCRT(fmin)( 2.0, 4.0), 2.0);
|
---|
717 | CHECK_DBL(RT_NOCRT(fmin)(-2.0, -4.0), -4.0);
|
---|
718 | CHECK_DBL(RT_NOCRT(fmin)(-2.0, -4.0e+10), -4.0e+10);
|
---|
719 | CHECK_DBL(RT_NOCRT(fmin)(+INFINITY, +INFINITY), +INFINITY);
|
---|
720 | CHECK_DBL(RT_NOCRT(fmin)(-INFINITY, -INFINITY), -INFINITY);
|
---|
721 | CHECK_DBL(RT_NOCRT(fmin)(+INFINITY, -INFINITY), -INFINITY);
|
---|
722 | CHECK_DBL(RT_NOCRT(fmin)(-INFINITY, +INFINITY), -INFINITY);
|
---|
723 | CHECK_DBL_SAME(fmin, ( 99.99, 99.87));
|
---|
724 | CHECK_DBL_SAME(fmin, ( -99.99, -99.87));
|
---|
725 | CHECK_DBL_SAME(fmin, (-987.453, 34599.87));
|
---|
726 | CHECK_DBL_SAME(fmin, (34599.87, -987.453));
|
---|
727 | CHECK_DBL_SAME(fmin, ( +0.0, -0.0));
|
---|
728 | CHECK_DBL_SAME(fmin, ( -0.0, +0.0));
|
---|
729 | CHECK_DBL_SAME(fmin, ( -0.0, -0.0));
|
---|
730 | CHECK_DBL_SAME(fmin, (+INFINITY, +INFINITY));
|
---|
731 | CHECK_DBL_SAME(fmin, (-INFINITY, -INFINITY));
|
---|
732 | CHECK_DBL_SAME(fmin, (+INFINITY, -INFINITY));
|
---|
733 | CHECK_DBL_SAME(fmin, (-INFINITY, +INFINITY));
|
---|
734 | CHECK_DBL_SAME(fmin, (RTStrNanDouble(NULL, true), -42.4242424242e222));
|
---|
735 | CHECK_DBL_SAME(fmin, (RTStrNanDouble(NULL, false), -42.4242424242e222));
|
---|
736 | CHECK_DBL_SAME(fmin, (-42.4242424242e-222, RTStrNanDouble(NULL, true)));
|
---|
737 | CHECK_DBL_SAME(fmin, (-42.4242424242e-222, RTStrNanDouble(NULL, false)));
|
---|
738 | CHECK_DBL_SAME(fmin, (RTStrNanDouble("2", false), RTStrNanDouble(NULL, false)));
|
---|
739 | CHECK_DBL_SAME(fmin, (RTStrNanDouble("3", true), RTStrNanDouble(NULL, false)));
|
---|
740 | CHECK_DBL_SAME(fmin, (RTStrNanDouble("4sig", true), RTStrNanDouble(NULL, false)));
|
---|
741 |
|
---|
742 | CHECK_FLT(RT_NOCRT(fmin)( 1.0f, 1.0f), 1.0f);
|
---|
743 | CHECK_FLT(RT_NOCRT(fmin)( 4.0f, 2.0f), 2.0f);
|
---|
744 | CHECK_FLT(RT_NOCRT(fmin)( 2.0f, 4.0f), 2.0f);
|
---|
745 | CHECK_FLT(RT_NOCRT(fmin)(-2.0f, -4.0f), -4.0f);
|
---|
746 | CHECK_FLT(RT_NOCRT(fmin)(-2.0f, -4.0e+10f), -4.0e+10f);
|
---|
747 | CHECK_FLT(RT_NOCRT(fmin)(+INFINITY, +INFINITY), +INFINITY);
|
---|
748 | CHECK_FLT(RT_NOCRT(fmin)(-INFINITY, -INFINITY), -INFINITY);
|
---|
749 | CHECK_FLT(RT_NOCRT(fmin)(+INFINITY, -INFINITY), -INFINITY);
|
---|
750 | CHECK_FLT(RT_NOCRT(fmin)(-INFINITY, +INFINITY), -INFINITY);
|
---|
751 | CHECK_FLT_SAME(fminf, ( 99.99f, 99.87f));
|
---|
752 | CHECK_FLT_SAME(fminf, ( -99.99f, -99.87f));
|
---|
753 | CHECK_FLT_SAME(fminf, (-987.453f, 34599.87f));
|
---|
754 | CHECK_FLT_SAME(fminf, (34599.87f, -987.453f));
|
---|
755 | CHECK_FLT_SAME(fminf, ( +0.0f, -0.0f));
|
---|
756 | CHECK_FLT_SAME(fminf, ( -0.0f, +0.0f));
|
---|
757 | CHECK_FLT_SAME(fminf, ( -0.0f, -0.0f));
|
---|
758 | CHECK_FLT_SAME(fminf, (+INFINITY, +INFINITY));
|
---|
759 | CHECK_FLT_SAME(fminf, (-INFINITY, -INFINITY));
|
---|
760 | CHECK_FLT_SAME(fminf, (+INFINITY, -INFINITY));
|
---|
761 | CHECK_FLT_SAME(fminf, (-INFINITY, +INFINITY));
|
---|
762 | CHECK_FLT_SAME(fminf, (RTStrNanFloat(NULL, true), -42.4242424242e22f));
|
---|
763 | CHECK_FLT_SAME(fminf, (RTStrNanFloat(NULL, false), -42.4242424242e22f));
|
---|
764 | CHECK_FLT_SAME(fminf, (-42.42424242e-22f, RTStrNanFloat(NULL, true)));
|
---|
765 | CHECK_FLT_SAME(fminf, (-42.42424242e-22f, RTStrNanFloat(NULL, false)));
|
---|
766 | CHECK_FLT_SAME(fminf, (RTStrNanFloat("2", false), RTStrNanFloat(NULL, false)));
|
---|
767 | CHECK_FLT_SAME(fminf, (RTStrNanFloat("3", true), RTStrNanFloat(NULL, false)));
|
---|
768 | CHECK_FLT_SAME(fminf, (RTStrNanFloat("4sig", true), RTStrNanFloat(NULL, false)));
|
---|
769 |
|
---|
770 | CHECK_LDBL(RT_NOCRT(fmin)( 1.0L, 1.0L), 1.0L);
|
---|
771 | CHECK_LDBL(RT_NOCRT(fmin)( 4.0L, 2.0L), 2.0L);
|
---|
772 | CHECK_LDBL(RT_NOCRT(fmin)( 2.0L, 4.0L), 2.0L);
|
---|
773 | CHECK_LDBL(RT_NOCRT(fmin)(-2.0L, -4.0L), -4.0L);
|
---|
774 | CHECK_LDBL(RT_NOCRT(fmin)(-2.0L, -4.0e+10L), -4.0e+10L);
|
---|
775 | CHECK_LDBL(RT_NOCRT(fmin)(+INFINITY, +INFINITY), +INFINITY);
|
---|
776 | CHECK_LDBL(RT_NOCRT(fmin)(-INFINITY, -INFINITY), -INFINITY);
|
---|
777 | CHECK_LDBL(RT_NOCRT(fmin)(+INFINITY, -INFINITY), -INFINITY);
|
---|
778 | CHECK_LDBL(RT_NOCRT(fmin)(-INFINITY, +INFINITY), -INFINITY);
|
---|
779 | CHECK_LDBL_SAME(fminl, ( 99.99L, 99.87L));
|
---|
780 | CHECK_LDBL_SAME(fminl, ( -99.99L, -99.87L));
|
---|
781 | CHECK_LDBL_SAME(fminl, (-987.453L, 34599.87L));
|
---|
782 | CHECK_LDBL_SAME(fminl, (34599.87L, -987.453L));
|
---|
783 | CHECK_LDBL_SAME(fminl, ( +0.0L, -0.0L));
|
---|
784 | CHECK_LDBL_SAME(fminl, ( -0.0L, +0.0L));
|
---|
785 | CHECK_LDBL_SAME(fminl, ( -0.0L, -0.0L));
|
---|
786 | CHECK_LDBL_SAME(fminl, (+INFINITY, +INFINITY));
|
---|
787 | CHECK_LDBL_SAME(fminl, (-INFINITY, -INFINITY));
|
---|
788 | CHECK_LDBL_SAME(fminl, (+INFINITY, -INFINITY));
|
---|
789 | CHECK_LDBL_SAME(fminl, (-INFINITY, +INFINITY));
|
---|
790 | CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble(NULL, true), -42.4242424242e222L));
|
---|
791 | CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble(NULL, false), -42.4242424242e222L));
|
---|
792 | CHECK_LDBL_SAME(fminl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, true)));
|
---|
793 | CHECK_LDBL_SAME(fminl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, false)));
|
---|
794 | CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble("2", false), RTStrNanLongDouble(NULL, false)));
|
---|
795 | CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble("3", true), RTStrNanLongDouble(NULL, false)));
|
---|
796 | CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble("4sig", true), RTStrNanLongDouble(NULL, false)));
|
---|
797 | }
|
---|
798 |
|
---|
799 |
|
---|
800 | void testIsInf()
|
---|
801 | {
|
---|
802 | RTTestSub(g_hTest, "isinf,__isinf[fl]");
|
---|
803 | #undef isinf
|
---|
804 | CHECK_INT(RT_NOCRT(isinf)( 1.0), 0);
|
---|
805 | CHECK_INT(RT_NOCRT(isinf)( 2394.2340e200), 0);
|
---|
806 | CHECK_INT(RT_NOCRT(isinf)(-2394.2340e200), 0);
|
---|
807 | CHECK_INT(RT_NOCRT(isinf)(-INFINITY), 1);
|
---|
808 | CHECK_INT(RT_NOCRT(isinf)(+INFINITY), 1);
|
---|
809 | CHECK_INT(RT_NOCRT(isinf)(RTStrNanDouble(NULL, true)), 0);
|
---|
810 | CHECK_INT(RT_NOCRT(isinf)(RTStrNanDouble("4sig", false)), 0);
|
---|
811 |
|
---|
812 | CHECK_INT(RT_NOCRT(__isinff)( 1.0f), 0);
|
---|
813 | CHECK_INT(RT_NOCRT(__isinff)( 2394.2340e20f), 0);
|
---|
814 | CHECK_INT(RT_NOCRT(__isinff)(-2394.2340e20f), 0);
|
---|
815 | CHECK_INT(RT_NOCRT(__isinff)(-INFINITY), 1);
|
---|
816 | CHECK_INT(RT_NOCRT(__isinff)(+INFINITY), 1);
|
---|
817 | CHECK_INT(RT_NOCRT(__isinff)(RTStrNanFloat(NULL, true)), 0);
|
---|
818 | CHECK_INT(RT_NOCRT(__isinff)(RTStrNanFloat("4sig", false)), 0);
|
---|
819 |
|
---|
820 | CHECK_INT(RT_NOCRT(__isinfl)( 1.0L), 0);
|
---|
821 | CHECK_INT(RT_NOCRT(__isinfl)( 2394.2340e200L), 0);
|
---|
822 | CHECK_INT(RT_NOCRT(__isinfl)(-2394.2340e200L), 0);
|
---|
823 | CHECK_INT(RT_NOCRT(__isinfl)(-INFINITY), 1);
|
---|
824 | CHECK_INT(RT_NOCRT(__isinfl)(+INFINITY), 1);
|
---|
825 | CHECK_INT(RT_NOCRT(__isinfl)(RTStrNanLongDouble(NULL, true)), 0);
|
---|
826 | CHECK_INT(RT_NOCRT(__isinfl)(RTStrNanLongDouble("4sig", false)), 0);
|
---|
827 | }
|
---|
828 |
|
---|
829 |
|
---|
830 | void testIsNan()
|
---|
831 | {
|
---|
832 | RTTestSub(g_hTest, "isnan[f],__isnanl");
|
---|
833 | #undef isnan
|
---|
834 | CHECK_INT(RT_NOCRT(isnan)( 0.0), 0);
|
---|
835 | CHECK_INT(RT_NOCRT(isnan)( 1.0), 0);
|
---|
836 | CHECK_INT(RT_NOCRT(isnan)( 2394.2340e200), 0);
|
---|
837 | CHECK_INT(RT_NOCRT(isnan)(-2394.2340e200), 0);
|
---|
838 | CHECK_INT(RT_NOCRT(isnan)(-INFINITY), 0);
|
---|
839 | CHECK_INT(RT_NOCRT(isnan)(+INFINITY), 0);
|
---|
840 | CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble(NULL, true)), 1);
|
---|
841 | CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble(NULL, false)), 1);
|
---|
842 | CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("435876quiet", false)), 1);
|
---|
843 | CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("435876quiet", true)), 1);
|
---|
844 | CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("678sig", false)), 1);
|
---|
845 | CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("45547absig", true)), 1);
|
---|
846 |
|
---|
847 | CHECK_INT(RT_NOCRT(isnanf)( 0.0f), 0);
|
---|
848 | CHECK_INT(RT_NOCRT(isnanf)( 1.0f), 0);
|
---|
849 | CHECK_INT(RT_NOCRT(isnanf)( 2394.2340e20f), 0);
|
---|
850 | CHECK_INT(RT_NOCRT(isnanf)(-2394.2340e20f), 0);
|
---|
851 | CHECK_INT(RT_NOCRT(isnanf)(-INFINITY), 0);
|
---|
852 | CHECK_INT(RT_NOCRT(isnanf)(+INFINITY), 0);
|
---|
853 | CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat(NULL, true)), 1);
|
---|
854 | CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat(NULL, false)), 1);
|
---|
855 | CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("9560q", false)), 1);
|
---|
856 | CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("aaaaq", true)), 1);
|
---|
857 | CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("4sig", false)), 1);
|
---|
858 | CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("69504sig", true)), 1);
|
---|
859 |
|
---|
860 | CHECK_INT(RT_NOCRT(__isnanl)( 0.0L), 0);
|
---|
861 | CHECK_INT(RT_NOCRT(__isnanl)( 1.0L), 0);
|
---|
862 | CHECK_INT(RT_NOCRT(__isnanl)( 2394.2340e200L), 0);
|
---|
863 | CHECK_INT(RT_NOCRT(__isnanl)(-2394.2340e200L), 0);
|
---|
864 | CHECK_INT(RT_NOCRT(__isnanl)(-INFINITY), 0);
|
---|
865 | CHECK_INT(RT_NOCRT(__isnanl)(+INFINITY), 0);
|
---|
866 | CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble(NULL, true)), 1);
|
---|
867 | CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble(NULL, false)), 1);
|
---|
868 | CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("bbbbq", false)), 1);
|
---|
869 | CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("11122q", true)), 1);
|
---|
870 | CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("4sig", false)), 1);
|
---|
871 | CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("23423406sig", true)), 1);
|
---|
872 | }
|
---|
873 |
|
---|
874 |
|
---|
875 | void testIsFinite()
|
---|
876 | {
|
---|
877 | RTTestSub(g_hTest, "__isfinite[fl]");
|
---|
878 | CHECK_INT(RT_NOCRT(__isfinite)( 1.0), 1);
|
---|
879 | CHECK_INT(RT_NOCRT(__isfinite)( 2394.2340e200), 1);
|
---|
880 | CHECK_INT(RT_NOCRT(__isfinite)(-2394.2340e200), 1);
|
---|
881 | CHECK_INT(RT_NOCRT(__isfinite)(-2.1984e-310), 1); /* subnormal */
|
---|
882 | CHECK_INT(RT_NOCRT(__isfinite)(-INFINITY), 0);
|
---|
883 | CHECK_INT(RT_NOCRT(__isfinite)(+INFINITY), 0);
|
---|
884 | CHECK_INT(RT_NOCRT(__isfinite)(RTStrNanDouble(NULL, true)), 0);
|
---|
885 | CHECK_INT(RT_NOCRT(__isfinite)(RTStrNanDouble("4sig", false)), 0);
|
---|
886 |
|
---|
887 | CHECK_INT(RT_NOCRT(__isfinitef)( 1.0f), 1);
|
---|
888 | CHECK_INT(RT_NOCRT(__isfinitef)( 2394.2340e20f), 1);
|
---|
889 | CHECK_INT(RT_NOCRT(__isfinitef)(-2394.2340e20f), 1);
|
---|
890 | CHECK_INT(RT_NOCRT(__isfinitef)(-2.1984e-40f), 1); /* subnormal */
|
---|
891 | CHECK_INT(RT_NOCRT(__isfinitef)(-INFINITY), 0);
|
---|
892 | CHECK_INT(RT_NOCRT(__isfinitef)(+INFINITY), 0);
|
---|
893 | CHECK_INT(RT_NOCRT(__isfinitef)(RTStrNanFloat(NULL, true)), 0);
|
---|
894 | CHECK_INT(RT_NOCRT(__isfinitef)(RTStrNanFloat("4sig", false)), 0);
|
---|
895 |
|
---|
896 | CHECK_INT(RT_NOCRT(__isfinitel)( 1.0L), 1);
|
---|
897 | CHECK_INT(RT_NOCRT(__isfinitel)( 2394.2340e200L), 1);
|
---|
898 | CHECK_INT(RT_NOCRT(__isfinitel)(-2394.2340e200L), 1);
|
---|
899 | #ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
900 | CHECK_INT(RT_NOCRT(__isfinitel)(-2.1984e-310L), 1); /* subnormal */
|
---|
901 | #else
|
---|
902 | CHECK_INT(RT_NOCRT(__isfinitel)(-2.1984e-4935L), 1); /* subnormal */
|
---|
903 | #endif
|
---|
904 | CHECK_INT(RT_NOCRT(__isfinitel)(-INFINITY), 0);
|
---|
905 | CHECK_INT(RT_NOCRT(__isfinitel)(+INFINITY), 0);
|
---|
906 | CHECK_INT(RT_NOCRT(__isfinitel)(RTStrNanLongDouble(NULL, true)), 0);
|
---|
907 | CHECK_INT(RT_NOCRT(__isfinitel)(RTStrNanLongDouble("4sig", false)), 0);
|
---|
908 | }
|
---|
909 |
|
---|
910 |
|
---|
911 | void testIsNormal()
|
---|
912 | {
|
---|
913 | RTTestSub(g_hTest, "__isnormal[fl]");
|
---|
914 | CHECK_INT(RT_NOCRT(__isnormal)( 1.0), 1);
|
---|
915 | CHECK_INT(RT_NOCRT(__isnormal)( 2394.2340e200), 1);
|
---|
916 | CHECK_INT(RT_NOCRT(__isnormal)(-2394.2340e200), 1);
|
---|
917 | CHECK_INT(RT_NOCRT(__isnormal)(-2.1984e-310), 0); /* subnormal */
|
---|
918 | CHECK_INT(RT_NOCRT(__isnormal)(-INFINITY), 0);
|
---|
919 | CHECK_INT(RT_NOCRT(__isnormal)(+INFINITY), 0);
|
---|
920 | CHECK_INT(RT_NOCRT(__isnormal)(RTStrNanDouble(NULL, true)), 0);
|
---|
921 | CHECK_INT(RT_NOCRT(__isnormal)(RTStrNanDouble("4sig", false)), 0);
|
---|
922 |
|
---|
923 | CHECK_INT(RT_NOCRT(__isnormalf)( 1.0f), 1);
|
---|
924 | CHECK_INT(RT_NOCRT(__isnormalf)( 2394.2340e20f), 1);
|
---|
925 | CHECK_INT(RT_NOCRT(__isnormalf)(-2394.2340e20f), 1);
|
---|
926 | CHECK_INT(RT_NOCRT(__isnormalf)(-2.1984e-40f), 0); /* subnormal */
|
---|
927 | CHECK_INT(RT_NOCRT(__isnormalf)(-INFINITY), 0);
|
---|
928 | CHECK_INT(RT_NOCRT(__isnormalf)(+INFINITY), 0);
|
---|
929 | CHECK_INT(RT_NOCRT(__isnormalf)(RTStrNanFloat(NULL, true)), 0);
|
---|
930 | CHECK_INT(RT_NOCRT(__isnormalf)(RTStrNanFloat("4sig", false)), 0);
|
---|
931 |
|
---|
932 | CHECK_INT(RT_NOCRT(__isnormall)( 1.0L), 1);
|
---|
933 | CHECK_INT(RT_NOCRT(__isnormall)( 2394.2340e200L), 1);
|
---|
934 | CHECK_INT(RT_NOCRT(__isnormall)(-2394.2340e200L), 1);
|
---|
935 | #ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
936 | CHECK_INT(RT_NOCRT(__isnormall)(-2.1984e-310L), 0); /* subnormal */
|
---|
937 | #else
|
---|
938 | CHECK_INT(RT_NOCRT(__isnormall)(-2.1984e-4935L), 0); /* subnormal */
|
---|
939 | #endif
|
---|
940 | CHECK_INT(RT_NOCRT(__isnormall)(-INFINITY), 0);
|
---|
941 | CHECK_INT(RT_NOCRT(__isnormall)(+INFINITY), 0);
|
---|
942 | CHECK_INT(RT_NOCRT(__isnormall)(RTStrNanLongDouble(NULL, true)), 0);
|
---|
943 | CHECK_INT(RT_NOCRT(__isnormall)(RTStrNanLongDouble("4sig", false)), 0);
|
---|
944 | }
|
---|
945 |
|
---|
946 |
|
---|
947 | void testFpClassify()
|
---|
948 | {
|
---|
949 | RTTestSub(g_hTest, "__fpclassify[dfl]");
|
---|
950 | CHECK_INT(RT_NOCRT(__fpclassifyd)( +0.0), RT_NOCRT_FP_ZERO);
|
---|
951 | CHECK_INT(RT_NOCRT(__fpclassifyd)( -0.0), RT_NOCRT_FP_ZERO);
|
---|
952 | CHECK_INT(RT_NOCRT(__fpclassifyd)( 1.0), RT_NOCRT_FP_NORMAL);
|
---|
953 | CHECK_INT(RT_NOCRT(__fpclassifyd)( 2394.2340e200), RT_NOCRT_FP_NORMAL);
|
---|
954 | CHECK_INT(RT_NOCRT(__fpclassifyd)(-2394.2340e200), RT_NOCRT_FP_NORMAL);
|
---|
955 | CHECK_INT(RT_NOCRT(__fpclassifyd)(-2.1984e-310), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
|
---|
956 | CHECK_INT(RT_NOCRT(__fpclassifyd)(-INFINITY), RT_NOCRT_FP_INFINITE);
|
---|
957 | CHECK_INT(RT_NOCRT(__fpclassifyd)(+INFINITY), RT_NOCRT_FP_INFINITE);
|
---|
958 | CHECK_INT(RT_NOCRT(__fpclassifyd)(RTStrNanDouble(NULL, true)), RT_NOCRT_FP_NAN);
|
---|
959 | CHECK_INT(RT_NOCRT(__fpclassifyd)(RTStrNanDouble("4sig", false)), RT_NOCRT_FP_NAN);
|
---|
960 |
|
---|
961 | CHECK_INT(RT_NOCRT(__fpclassifyf)( +0.0f), RT_NOCRT_FP_ZERO);
|
---|
962 | CHECK_INT(RT_NOCRT(__fpclassifyf)( -0.0f), RT_NOCRT_FP_ZERO);
|
---|
963 | CHECK_INT(RT_NOCRT(__fpclassifyf)( 1.0f), RT_NOCRT_FP_NORMAL);
|
---|
964 | CHECK_INT(RT_NOCRT(__fpclassifyf)( 2394.2340e20f), RT_NOCRT_FP_NORMAL);
|
---|
965 | CHECK_INT(RT_NOCRT(__fpclassifyf)(-2394.2340e20f), RT_NOCRT_FP_NORMAL);
|
---|
966 | CHECK_INT(RT_NOCRT(__fpclassifyf)(-2.1984e-40f), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
|
---|
967 | CHECK_INT(RT_NOCRT(__fpclassifyf)(-INFINITY), RT_NOCRT_FP_INFINITE);
|
---|
968 | CHECK_INT(RT_NOCRT(__fpclassifyf)(+INFINITY), RT_NOCRT_FP_INFINITE);
|
---|
969 | CHECK_INT(RT_NOCRT(__fpclassifyf)(RTStrNanFloat(NULL, true)), RT_NOCRT_FP_NAN);
|
---|
970 | CHECK_INT(RT_NOCRT(__fpclassifyf)(RTStrNanFloat("4sig", false)), RT_NOCRT_FP_NAN);
|
---|
971 |
|
---|
972 | CHECK_INT(RT_NOCRT(__fpclassifyl)( +0.0L), RT_NOCRT_FP_ZERO);
|
---|
973 | CHECK_INT(RT_NOCRT(__fpclassifyl)( -0.0L), RT_NOCRT_FP_ZERO);
|
---|
974 | CHECK_INT(RT_NOCRT(__fpclassifyl)( 1.0L), RT_NOCRT_FP_NORMAL);
|
---|
975 | CHECK_INT(RT_NOCRT(__fpclassifyl)( 2394.2340e200L), RT_NOCRT_FP_NORMAL);
|
---|
976 | CHECK_INT(RT_NOCRT(__fpclassifyl)(-2394.2340e200L), RT_NOCRT_FP_NORMAL);
|
---|
977 | #ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
978 | CHECK_INT(RT_NOCRT(__fpclassifyl)(-2.1984e-310L), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
|
---|
979 | #else
|
---|
980 | CHECK_INT(RT_NOCRT(__fpclassifyl)(-2.1984e-4935L), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
|
---|
981 | #endif
|
---|
982 | CHECK_INT(RT_NOCRT(__fpclassifyl)(-INFINITY), RT_NOCRT_FP_INFINITE);
|
---|
983 | CHECK_INT(RT_NOCRT(__fpclassifyl)(+INFINITY), RT_NOCRT_FP_INFINITE);
|
---|
984 | CHECK_INT(RT_NOCRT(__fpclassifyl)(RTStrNanLongDouble(NULL, true)), RT_NOCRT_FP_NAN);
|
---|
985 | CHECK_INT(RT_NOCRT(__fpclassifyl)(RTStrNanLongDouble("4sig", false)), RT_NOCRT_FP_NAN);
|
---|
986 | }
|
---|
987 |
|
---|
988 |
|
---|
989 | void testSignBit()
|
---|
990 | {
|
---|
991 | RTTestSub(g_hTest, "__signbit[fl]");
|
---|
992 | CHECK_INT(RT_NOCRT(__signbit)( +0.0), 0);
|
---|
993 | CHECK_INT(RT_NOCRT(__signbit)( -0.0), 1);
|
---|
994 | CHECK_INT(RT_NOCRT(__signbit)( 1.0), 0);
|
---|
995 | CHECK_INT(RT_NOCRT(__signbit)( 2394.2340e200), 0);
|
---|
996 | CHECK_INT(RT_NOCRT(__signbit)(-2394.2340e200), 1);
|
---|
997 | CHECK_INT(RT_NOCRT(__signbit)(-2.1984e-310), 1); /* subnormal */
|
---|
998 | CHECK_INT(RT_NOCRT(__signbit)(-INFINITY), 1);
|
---|
999 | CHECK_INT(RT_NOCRT(__signbit)(+INFINITY), 0);
|
---|
1000 | CHECK_INT(RT_NOCRT(__signbit)(RTStrNanDouble(NULL, true)), 0);
|
---|
1001 | CHECK_INT(RT_NOCRT(__signbit)(RTStrNanDouble("4sig", false)), 1);
|
---|
1002 |
|
---|
1003 | CHECK_INT(RT_NOCRT(__signbitf)( +0.0f), 0);
|
---|
1004 | CHECK_INT(RT_NOCRT(__signbitf)( -0.0f), 1);
|
---|
1005 | CHECK_INT(RT_NOCRT(__signbitf)( 1.0f), 0);
|
---|
1006 | CHECK_INT(RT_NOCRT(__signbitf)( 2394.2340e20f), 0);
|
---|
1007 | CHECK_INT(RT_NOCRT(__signbitf)(-2394.2340e20f), 1);
|
---|
1008 | CHECK_INT(RT_NOCRT(__signbitf)(-2.1984e-40f), 1); /* subnormal */
|
---|
1009 | CHECK_INT(RT_NOCRT(__signbitf)(-INFINITY), 1);
|
---|
1010 | CHECK_INT(RT_NOCRT(__signbitf)(+INFINITY), 0);
|
---|
1011 | CHECK_INT(RT_NOCRT(__signbitf)(RTStrNanFloat(NULL, true)), 0);
|
---|
1012 | CHECK_INT(RT_NOCRT(__signbitf)(RTStrNanFloat("4sig", false)), 1);
|
---|
1013 |
|
---|
1014 | CHECK_INT(RT_NOCRT(__signbitl)( +0.0L), 0);
|
---|
1015 | CHECK_INT(RT_NOCRT(__signbitl)( -0.0L), 1);
|
---|
1016 | CHECK_INT(RT_NOCRT(__signbitl)( 1.0L), 0);
|
---|
1017 | CHECK_INT(RT_NOCRT(__signbitl)( 2394.2340e200L), 0);
|
---|
1018 | CHECK_INT(RT_NOCRT(__signbitl)(-2394.2340e200L), 1);
|
---|
1019 | #ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
1020 | CHECK_INT(RT_NOCRT(__signbitl)(-2.1984e-310L), 1); /* subnormal */
|
---|
1021 | #else
|
---|
1022 | CHECK_INT(RT_NOCRT(__signbitl)(-2.1984e-4935L), 1); /* subnormal */
|
---|
1023 | #endif
|
---|
1024 | CHECK_INT(RT_NOCRT(__signbitl)(-INFINITY), 1);
|
---|
1025 | CHECK_INT(RT_NOCRT(__signbitl)(+INFINITY), 0);
|
---|
1026 | CHECK_INT(RT_NOCRT(__signbitl)(RTStrNanLongDouble(NULL, true)), 0);
|
---|
1027 | CHECK_INT(RT_NOCRT(__signbitl)(RTStrNanLongDouble("4sig", false)), 1);
|
---|
1028 | }
|
---|
1029 |
|
---|
1030 |
|
---|
1031 | void testFrExp()
|
---|
1032 | {
|
---|
1033 | RTTestSub(g_hTest, "frexp[fl]");
|
---|
1034 | int iExp;
|
---|
1035 |
|
---|
1036 | CHECK_DBL(RT_NOCRT(frexp)( +1.0, &iExp), +0.50000000000000000000); CHECK_INT(iExp, 1);
|
---|
1037 | CHECK_DBL(RT_NOCRT(frexp)( -1.0, &iExp), -0.50000000000000000000); CHECK_INT(iExp, 1);
|
---|
1038 | CHECK_DBL(RT_NOCRT(frexp)( +42.22, &iExp), +0.65968749999999998224); CHECK_INT(iExp, 6);
|
---|
1039 | CHECK_DBL(RT_NOCRT(frexp)( -42.22, &iExp), -0.65968749999999998224); CHECK_INT(iExp, 6);
|
---|
1040 | CHECK_DBL(RT_NOCRT(frexp)( +88888.88888, &iExp), +0.67816840270996092688); CHECK_INT(iExp, 17);
|
---|
1041 | CHECK_DBL(RT_NOCRT(frexp)( -999999.9999, &iExp), -0.95367431631088261934); CHECK_INT(iExp, 20);
|
---|
1042 | CHECK_DBL(RT_NOCRT(frexp)( +1.3942340e+200, &iExp), +0.91072771427195720051); CHECK_INT(iExp, 665);
|
---|
1043 | CHECK_DBL(RT_NOCRT(frexp)( -1.3942340e+200, &iExp), -0.91072771427195720051); CHECK_INT(iExp, 665);
|
---|
1044 | CHECK_DBL(RT_NOCRT(frexp)( -1.1984e-310, &iExp), -0.68939374490207683266); CHECK_INT(iExp, -1029); /* subnormal */
|
---|
1045 | CHECK_DBL(RT_NOCRT(frexp)( -INFINITY, &iExp), -INFINITY); CHECK_INT(iExp, INT_MIN);
|
---|
1046 | CHECK_DBL(RT_NOCRT(frexp)( +INFINITY, &iExp), +INFINITY); CHECK_INT(iExp, INT_MAX);
|
---|
1047 | CHECK_DBL(RT_NOCRT(frexp)( RTStrNanDouble(NULL, true), &iExp), RTStrNanDouble(NULL, true)); CHECK_INT(iExp, INT_MAX);
|
---|
1048 | CHECK_DBL(RT_NOCRT(frexp)( RTStrNanDouble("4sig", false), &iExp), RTStrNanDouble("4sig", false)); CHECK_INT(iExp, INT_MIN);
|
---|
1049 |
|
---|
1050 | CHECK_FLT(RT_NOCRT(frexpf)( +1.0f, &iExp), +0.500000000000000f); CHECK_INT(iExp, 1);
|
---|
1051 | CHECK_FLT(RT_NOCRT(frexpf)( -1.0f, &iExp), -0.500000000000000f); CHECK_INT(iExp, 1);
|
---|
1052 | CHECK_FLT(RT_NOCRT(frexpf)( +42.22f, &iExp), +0.659687519073486f); CHECK_INT(iExp, 6);
|
---|
1053 | CHECK_FLT(RT_NOCRT(frexpf)( -42.22f, &iExp), -0.659687519073486f); CHECK_INT(iExp, 6);
|
---|
1054 | CHECK_FLT(RT_NOCRT(frexpf)( +88888.88888f, &iExp), +0.678168416023254f); CHECK_INT(iExp, 17);
|
---|
1055 | CHECK_FLT(RT_NOCRT(frexpf)( -999999.9999f, &iExp), -0.953674316406250f); CHECK_INT(iExp, 20);
|
---|
1056 | CHECK_FLT(RT_NOCRT(frexpf)( +1.3942340e+32f, &iExp), +0.859263062477112f); CHECK_INT(iExp, 107);
|
---|
1057 | CHECK_FLT(RT_NOCRT(frexpf)( -1.3942340e+35f, &iExp), -0.839124083518982f); CHECK_INT(iExp, 117);
|
---|
1058 | CHECK_FLT(RT_NOCRT(frexpf)( -2.1984e-40f, &iExp), -0.598461151123047f); CHECK_INT(iExp, -131);
|
---|
1059 | CHECK_FLT(RT_NOCRT(frexpf)( -(float)INFINITY, &iExp), -(float)INFINITY); CHECK_INT(iExp, INT_MIN);
|
---|
1060 | CHECK_FLT(RT_NOCRT(frexpf)( +(float)INFINITY, &iExp), +(float)INFINITY); CHECK_INT(iExp, INT_MAX);
|
---|
1061 | CHECK_FLT(RT_NOCRT(frexpf)( RTStrNanFloat(NULL, true), &iExp), RTStrNanFloat(NULL, true)); CHECK_INT(iExp, INT_MAX);
|
---|
1062 | CHECK_FLT(RT_NOCRT(frexpf)( RTStrNanFloat("4sig", false), &iExp), RTStrNanFloat("4sig", false)); CHECK_INT(iExp, INT_MIN);
|
---|
1063 |
|
---|
1064 | #ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
1065 | CHECK_LDBL(RT_NOCRT(frexpl)( +1.0L, &iExp), +0.50000000000000000000L); CHECK_INT(iExp, 1);
|
---|
1066 | CHECK_LDBL(RT_NOCRT(frexpl)( -1.0L, &iExp), -0.50000000000000000000L); CHECK_INT(iExp, 1);
|
---|
1067 | CHECK_LDBL(RT_NOCRT(frexpl)( +42.22L, &iExp), +0.65968749999999998224L); CHECK_INT(iExp, 6);
|
---|
1068 | CHECK_LDBL(RT_NOCRT(frexpl)( -42.22L, &iExp), -0.65968749999999998224L); CHECK_INT(iExp, 6);
|
---|
1069 | CHECK_LDBL(RT_NOCRT(frexpl)( +88888.88888L, &iExp), +0.67816840270996092688L); CHECK_INT(iExp, 17);
|
---|
1070 | CHECK_LDBL(RT_NOCRT(frexpl)( -999999.9999L, &iExp), -0.95367431631088261934L); CHECK_INT(iExp, 20);
|
---|
1071 | CHECK_LDBL(RT_NOCRT(frexpl)( +1.3942340e+200L, &iExp), +0.91072771427195720051L); CHECK_INT(iExp, 665);
|
---|
1072 | CHECK_LDBL(RT_NOCRT(frexpl)( -1.3942340e+200L, &iExp), -0.91072771427195720051L); CHECK_INT(iExp, 665);
|
---|
1073 | CHECK_LDBL(RT_NOCRT(frexpl)( -1.1984e-310L, &iExp), -0.68939374490207683266L); CHECK_INT(iExp, -1029); /* subnormal */
|
---|
1074 | #else
|
---|
1075 | CHECK_LDBL(RT_NOCRT(frexpl)( +1.0L, &iExp), +0.500000000000000000000000000000000L); CHECK_INT(iExp, 1);
|
---|
1076 | CHECK_LDBL(RT_NOCRT(frexpl)( -1.0L, &iExp), -0.500000000000000000000000000000000L); CHECK_INT(iExp, 1);
|
---|
1077 | CHECK_LDBL(RT_NOCRT(frexpl)( +42.22L, &iExp), +0.659687500000000000017347234759768L); CHECK_INT(iExp, 6);
|
---|
1078 | CHECK_LDBL(RT_NOCRT(frexpl)( -42.22L, &iExp), -0.659687500000000000017347234759768L); CHECK_INT(iExp, 6);
|
---|
1079 | CHECK_LDBL(RT_NOCRT(frexpl)( +8888888.88888888L, &iExp), +0.529819064670138359081450613041753L); CHECK_INT(iExp, 24);
|
---|
1080 | CHECK_LDBL(RT_NOCRT(frexpl)( -999999999999.9999999L, &iExp), -0.909494701772928237806618845251450L); CHECK_INT(iExp, 40);
|
---|
1081 | CHECK_LDBL(RT_NOCRT(frexpl)( +1.3942340e+4001L, &iExp), +0.713893296064537648672014558126619L); CHECK_INT(iExp, 13292);
|
---|
1082 | CHECK_LDBL(RT_NOCRT(frexpl)( -1.3942340e+2000L, &iExp), -0.630978384969008136966966970859971L); CHECK_INT(iExp, 6645);
|
---|
1083 | CHECK_LDBL(RT_NOCRT(frexpl)( -2.1984e-4935L, &iExp), -0.669569464164694649888076583010843L); CHECK_INT(iExp, -16392);
|
---|
1084 | #endif
|
---|
1085 | CHECK_LDBL(RT_NOCRT(frexpl)( -(long double)INFINITY, &iExp), -(long double)INFINITY); CHECK_INT(iExp, INT_MIN);
|
---|
1086 | CHECK_LDBL(RT_NOCRT(frexpl)( +(long double)INFINITY, &iExp), +(long double)INFINITY); CHECK_INT(iExp, INT_MAX);
|
---|
1087 | CHECK_LDBL(RT_NOCRT(frexpl)(RTStrNanLongDouble(NULL, true), &iExp), RTStrNanLongDouble(NULL, true)); CHECK_INT(iExp, INT_MAX);
|
---|
1088 | CHECK_LDBL(RT_NOCRT(frexpl)(RTStrNanLongDouble("4sig", false), &iExp), RTStrNanLongDouble("4sig", false)); CHECK_INT(iExp, INT_MIN);
|
---|
1089 | }
|
---|
1090 |
|
---|
1091 |
|
---|
1092 | void testCeil()
|
---|
1093 | {
|
---|
1094 | RTTestSub(g_hTest, "ceil[f]");
|
---|
1095 | CHECK_DBL(RT_NOCRT(ceil)( +0.0), +0.0);
|
---|
1096 | CHECK_DBL(RT_NOCRT(ceil)( -0.0), -0.0);
|
---|
1097 | CHECK_DBL(RT_NOCRT(ceil)( -42.0), -42.0);
|
---|
1098 | CHECK_DBL(RT_NOCRT(ceil)( -42.5), -42.0);
|
---|
1099 | CHECK_DBL(RT_NOCRT(ceil)( +42.5), +43.0);
|
---|
1100 | CHECK_DBL(RT_NOCRT(ceil)(-42.25), -42.0);
|
---|
1101 | CHECK_DBL(RT_NOCRT(ceil)(+42.25), +43.0);
|
---|
1102 | CHECK_DBL_SAME(ceil,( -0.0));
|
---|
1103 | CHECK_DBL_SAME(ceil,( +0.0));
|
---|
1104 | CHECK_DBL_SAME(ceil,( +42.25));
|
---|
1105 | CHECK_DBL_SAME(ceil,(+1234.60958634e+10));
|
---|
1106 | CHECK_DBL_SAME(ceil,(-1234.60958634e+10));
|
---|
1107 | CHECK_DBL_SAME(ceil,( -1234.499999e+10));
|
---|
1108 | CHECK_DBL_SAME(ceil,( -1234.499999e-10));
|
---|
1109 | CHECK_DBL_SAME(ceil,( -2.1984e-310)); /* subnormal */
|
---|
1110 | CHECK_DBL_SAME(ceil,(-INFINITY));
|
---|
1111 | CHECK_DBL_SAME(ceil,(+INFINITY));
|
---|
1112 | CHECK_DBL_SAME(ceil,(RTStrNanDouble(NULL, true)));
|
---|
1113 | CHECK_DBL_SAME(ceil,(RTStrNanDouble("s", false)));
|
---|
1114 |
|
---|
1115 | CHECK_DBL(RT_NOCRT(ceilf)( +0.0f), +0.0f);
|
---|
1116 | CHECK_DBL(RT_NOCRT(ceilf)( -0.0f), -0.0f);
|
---|
1117 | CHECK_DBL(RT_NOCRT(ceilf)( -42.0f), -42.0f);
|
---|
1118 | CHECK_DBL(RT_NOCRT(ceilf)( -42.5f), -42.0f);
|
---|
1119 | CHECK_DBL(RT_NOCRT(ceilf)( +42.5f), +43.0f);
|
---|
1120 | CHECK_DBL(RT_NOCRT(ceilf)(-42.25f), -42.0f);
|
---|
1121 | CHECK_DBL(RT_NOCRT(ceilf)(+42.25f), +43.0f);
|
---|
1122 | CHECK_DBL_SAME(ceilf,( -0.0f));
|
---|
1123 | CHECK_DBL_SAME(ceilf,( +0.0f));
|
---|
1124 | CHECK_DBL_SAME(ceilf,( +42.25f));
|
---|
1125 | CHECK_DBL_SAME(ceilf,(+1234.60958634e+10f));
|
---|
1126 | CHECK_DBL_SAME(ceilf,(-1234.60958634e+10f));
|
---|
1127 | CHECK_DBL_SAME(ceilf,( -1234.499999e+10f));
|
---|
1128 | CHECK_DBL_SAME(ceilf,( -1234.499999e-10f));
|
---|
1129 | CHECK_DBL_SAME(ceilf,( -2.1984e-40f)); /* subnormal */
|
---|
1130 | CHECK_DBL_SAME(ceilf,(-INFINITY));
|
---|
1131 | CHECK_DBL_SAME(ceilf,(+INFINITY));
|
---|
1132 | CHECK_DBL_SAME(ceilf,(RTStrNanFloat(NULL, true)));
|
---|
1133 | CHECK_DBL_SAME(ceilf,(RTStrNanFloat("s", false)));
|
---|
1134 | }
|
---|
1135 |
|
---|
1136 |
|
---|
1137 | void testFloor()
|
---|
1138 | {
|
---|
1139 | RTTestSub(g_hTest, "floor[f]");
|
---|
1140 | CHECK_DBL(RT_NOCRT(floor)( +0.0), +0.0);
|
---|
1141 | CHECK_DBL(RT_NOCRT(floor)( -0.0), -0.0);
|
---|
1142 | CHECK_DBL(RT_NOCRT(floor)( -42.0), -42.0);
|
---|
1143 | CHECK_DBL(RT_NOCRT(floor)( -42.5), -43.0);
|
---|
1144 | CHECK_DBL(RT_NOCRT(floor)( +42.5), +42.0);
|
---|
1145 | CHECK_DBL(RT_NOCRT(floor)(-42.25), -43.0);
|
---|
1146 | CHECK_DBL(RT_NOCRT(floor)(+42.25), +42.0);
|
---|
1147 | CHECK_DBL_SAME(floor,( -0.0));
|
---|
1148 | CHECK_DBL_SAME(floor,( +0.0));
|
---|
1149 | CHECK_DBL_SAME(floor,( +42.25));
|
---|
1150 | CHECK_DBL_SAME(floor,(+1234.60958634e+10));
|
---|
1151 | CHECK_DBL_SAME(floor,(-1234.60958634e+10));
|
---|
1152 | CHECK_DBL_SAME(floor,( -1234.499999e+10));
|
---|
1153 | CHECK_DBL_SAME(floor,( -1234.499999e-10));
|
---|
1154 | CHECK_DBL_SAME(floor,( -2.1984e-310)); /* subnormal */
|
---|
1155 | CHECK_DBL_SAME(floor,(-INFINITY));
|
---|
1156 | CHECK_DBL_SAME(floor,(+INFINITY));
|
---|
1157 | CHECK_DBL_SAME(floor,(RTStrNanDouble(NULL, true)));
|
---|
1158 | CHECK_DBL_SAME(floor,(RTStrNanDouble("s", false)));
|
---|
1159 |
|
---|
1160 | CHECK_DBL(RT_NOCRT(floorf)( +0.0f), +0.0f);
|
---|
1161 | CHECK_DBL(RT_NOCRT(floorf)( -0.0f), -0.0f);
|
---|
1162 | CHECK_DBL(RT_NOCRT(floorf)( -42.0f), -42.0f);
|
---|
1163 | CHECK_DBL(RT_NOCRT(floorf)( -42.5f), -43.0f);
|
---|
1164 | CHECK_DBL(RT_NOCRT(floorf)( +42.5f), +42.0f);
|
---|
1165 | CHECK_DBL(RT_NOCRT(floorf)(-42.25f), -43.0f);
|
---|
1166 | CHECK_DBL(RT_NOCRT(floorf)(+42.25f), +42.0f);
|
---|
1167 | CHECK_DBL_SAME(floorf,( -0.0f));
|
---|
1168 | CHECK_DBL_SAME(floorf,( +0.0f));
|
---|
1169 | CHECK_DBL_SAME(floorf,( +42.25f));
|
---|
1170 | CHECK_DBL_SAME(floorf,(+1234.60958634e+10f));
|
---|
1171 | CHECK_DBL_SAME(floorf,(-1234.60958634e+10f));
|
---|
1172 | CHECK_DBL_SAME(floorf,( -1234.499999e+10f));
|
---|
1173 | CHECK_DBL_SAME(floorf,( -1234.499999e-10f));
|
---|
1174 | CHECK_DBL_SAME(floorf,( -2.1984e-40f)); /* subnormal */
|
---|
1175 | CHECK_DBL_SAME(floorf,(-INFINITY));
|
---|
1176 | CHECK_DBL_SAME(floorf,(+INFINITY));
|
---|
1177 | CHECK_DBL_SAME(floorf,(RTStrNanFloat(NULL, true)));
|
---|
1178 | CHECK_DBL_SAME(floorf,(RTStrNanFloat("s", false)));
|
---|
1179 | }
|
---|
1180 |
|
---|
1181 |
|
---|
1182 | void testTrunc()
|
---|
1183 | {
|
---|
1184 | RTTestSub(g_hTest, "trunc[f]");
|
---|
1185 | CHECK_DBL(RT_NOCRT(trunc)( +0.0), +0.0);
|
---|
1186 | CHECK_DBL(RT_NOCRT(trunc)( -0.0), -0.0);
|
---|
1187 | CHECK_DBL(RT_NOCRT(trunc)( -42.0), -42.0);
|
---|
1188 | CHECK_DBL(RT_NOCRT(trunc)( -42.5), -42.0);
|
---|
1189 | CHECK_DBL(RT_NOCRT(trunc)( +42.5), +42.0);
|
---|
1190 | CHECK_DBL(RT_NOCRT(trunc)(-42.25), -42.0);
|
---|
1191 | CHECK_DBL(RT_NOCRT(trunc)(+42.25), +42.0);
|
---|
1192 | CHECK_DBL_SAME(trunc,( -0.0));
|
---|
1193 | CHECK_DBL_SAME(trunc,( +0.0));
|
---|
1194 | CHECK_DBL_SAME(trunc,( +42.25));
|
---|
1195 | CHECK_DBL_SAME(trunc,(+1234.60958634e+10));
|
---|
1196 | CHECK_DBL_SAME(trunc,(-1234.60958634e+10));
|
---|
1197 | CHECK_DBL_SAME(trunc,( -1234.499999e+10));
|
---|
1198 | CHECK_DBL_SAME(trunc,( -1234.499999e-10));
|
---|
1199 | CHECK_DBL_SAME(trunc,( -2.1984e-310)); /* subnormal */
|
---|
1200 | CHECK_DBL_SAME(trunc,(-INFINITY));
|
---|
1201 | CHECK_DBL_SAME(trunc,(+INFINITY));
|
---|
1202 | CHECK_DBL_SAME(trunc,(RTStrNanDouble(NULL, true)));
|
---|
1203 | CHECK_DBL_SAME(trunc,(RTStrNanDouble("s", false)));
|
---|
1204 |
|
---|
1205 | CHECK_DBL(RT_NOCRT(truncf)( +0.0f), +0.0f);
|
---|
1206 | CHECK_DBL(RT_NOCRT(truncf)( -0.0f), -0.0f);
|
---|
1207 | CHECK_DBL(RT_NOCRT(truncf)( -42.0f), -42.0f);
|
---|
1208 | CHECK_DBL(RT_NOCRT(truncf)( -42.5f), -42.0f);
|
---|
1209 | CHECK_DBL(RT_NOCRT(truncf)( +42.5f), +42.0f);
|
---|
1210 | CHECK_DBL(RT_NOCRT(truncf)(-42.25f), -42.0f);
|
---|
1211 | CHECK_DBL(RT_NOCRT(truncf)(+42.25f), +42.0f);
|
---|
1212 | CHECK_DBL_SAME(truncf,( -0.0f));
|
---|
1213 | CHECK_DBL_SAME(truncf,( +0.0f));
|
---|
1214 | CHECK_DBL_SAME(truncf,( +42.25f));
|
---|
1215 | CHECK_DBL_SAME(truncf,(+1234.60958634e+10f));
|
---|
1216 | CHECK_DBL_SAME(truncf,(-1234.60958634e+10f));
|
---|
1217 | CHECK_DBL_SAME(truncf,( -1234.499999e+10f));
|
---|
1218 | CHECK_DBL_SAME(truncf,( -1234.499999e-10f));
|
---|
1219 | CHECK_DBL_SAME(truncf,( -2.1984e-40f)); /* subnormal */
|
---|
1220 | CHECK_DBL_SAME(truncf,(-INFINITY));
|
---|
1221 | CHECK_DBL_SAME(truncf,(+INFINITY));
|
---|
1222 | CHECK_DBL_SAME(truncf,(RTStrNanFloat(NULL, true)));
|
---|
1223 | CHECK_DBL_SAME(truncf,(RTStrNanFloat("s", false)));
|
---|
1224 | }
|
---|
1225 |
|
---|
1226 |
|
---|
1227 | void testRound()
|
---|
1228 | {
|
---|
1229 | RTTestSub(g_hTest, "round[f]");
|
---|
1230 | CHECK_DBL(RT_NOCRT(round)( +0.0), +0.0);
|
---|
1231 | CHECK_DBL(RT_NOCRT(round)( -0.0), -0.0);
|
---|
1232 | CHECK_DBL(RT_NOCRT(round)( -42.0), -42.0);
|
---|
1233 | CHECK_DBL(RT_NOCRT(round)( -42.5), -43.0);
|
---|
1234 | CHECK_DBL(RT_NOCRT(round)( +42.5), +43.0);
|
---|
1235 | CHECK_DBL(RT_NOCRT(round)(-42.25), -42.0);
|
---|
1236 | CHECK_DBL(RT_NOCRT(round)(+42.25), +42.0);
|
---|
1237 | CHECK_DBL_SAME(round,( -0.0));
|
---|
1238 | CHECK_DBL_SAME(round,( +0.0));
|
---|
1239 | CHECK_DBL_SAME(round,( +42.25));
|
---|
1240 | CHECK_DBL_SAME(round,(+1234.60958634e+10));
|
---|
1241 | CHECK_DBL_SAME(round,(-1234.60958634e+10));
|
---|
1242 | CHECK_DBL_SAME(round,( -1234.499999e+10));
|
---|
1243 | CHECK_DBL_SAME(round,( -1234.499999e-10));
|
---|
1244 | CHECK_DBL_SAME(round,( -2.1984e-310)); /* subnormal */
|
---|
1245 | CHECK_DBL_SAME(round,(-INFINITY));
|
---|
1246 | CHECK_DBL_SAME(round,(+INFINITY));
|
---|
1247 | CHECK_DBL_SAME(round,(RTStrNanDouble(NULL, true)));
|
---|
1248 | CHECK_DBL_SAME(round,(RTStrNanDouble("s", false)));
|
---|
1249 |
|
---|
1250 | CHECK_DBL(RT_NOCRT(roundf)( +0.0f), +0.0f);
|
---|
1251 | CHECK_DBL(RT_NOCRT(roundf)( -0.0f), -0.0f);
|
---|
1252 | CHECK_DBL(RT_NOCRT(roundf)( -42.0f), -42.0f);
|
---|
1253 | CHECK_DBL(RT_NOCRT(roundf)( -42.5f), -43.0f);
|
---|
1254 | CHECK_DBL(RT_NOCRT(roundf)( +42.5f), +43.0f);
|
---|
1255 | CHECK_DBL(RT_NOCRT(roundf)(-42.25f), -42.0f);
|
---|
1256 | CHECK_DBL(RT_NOCRT(roundf)(+42.25f), +42.0f);
|
---|
1257 | CHECK_DBL_SAME(roundf,( -0.0f));
|
---|
1258 | CHECK_DBL_SAME(roundf,( +0.0f));
|
---|
1259 | CHECK_DBL_SAME(roundf,( +42.25f));
|
---|
1260 | CHECK_DBL_SAME(roundf,(+1234.60958634e+10f));
|
---|
1261 | CHECK_DBL_SAME(roundf,(-1234.60958634e+10f));
|
---|
1262 | CHECK_DBL_SAME(roundf,( -1234.499999e+10f));
|
---|
1263 | CHECK_DBL_SAME(roundf,( -1234.499999e-10f));
|
---|
1264 | CHECK_DBL_SAME(roundf,( -2.1984e-40f)); /* subnormal */
|
---|
1265 | CHECK_DBL_SAME(roundf,(-INFINITY));
|
---|
1266 | CHECK_DBL_SAME(roundf,(+INFINITY));
|
---|
1267 | CHECK_DBL_SAME(roundf,(RTStrNanFloat(NULL, true)));
|
---|
1268 | CHECK_DBL_SAME(roundf,(RTStrNanFloat("s", false)));
|
---|
1269 | }
|
---|
1270 |
|
---|
1271 |
|
---|
1272 | void testRInt()
|
---|
1273 | {
|
---|
1274 | RTTestSub(g_hTest, "rint[f]");
|
---|
1275 |
|
---|
1276 | /*
|
---|
1277 | * Round nearest.
|
---|
1278 | */
|
---|
1279 | #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
|
---|
1280 | AssertCompile(RT_NOCRT_FE_TONEAREST == X86_FCW_RC_NEAREST);
|
---|
1281 | AssertCompile(RT_NOCRT_FE_DOWNWARD == X86_FCW_RC_DOWN);
|
---|
1282 | AssertCompile(RT_NOCRT_FE_UPWARD == X86_FCW_RC_UP);
|
---|
1283 | AssertCompile(RT_NOCRT_FE_TOWARDZERO == X86_FCW_RC_ZERO);
|
---|
1284 | AssertCompile(RT_NOCRT_FE_ROUND_MASK == X86_FCW_RC_MASK);
|
---|
1285 | #endif
|
---|
1286 | int const iSavedMode = RT_NOCRT(fegetround)();
|
---|
1287 | if (iSavedMode != FE_TONEAREST)
|
---|
1288 | RTTestFailed(g_hTest, "expected FE_TONEAREST as default rounding mode, not %#x (%d)", iSavedMode, iSavedMode);
|
---|
1289 | RT_NOCRT(fesetround)(FE_TONEAREST);
|
---|
1290 |
|
---|
1291 | CHECK_DBL(RT_NOCRT(rint)( +0.0), +0.0);
|
---|
1292 | CHECK_DBL(RT_NOCRT(rint)( -0.0), -0.0);
|
---|
1293 | CHECK_DBL(RT_NOCRT(rint)( -42.0), -42.0);
|
---|
1294 | CHECK_DBL(RT_NOCRT(rint)( -42.5), -42.0);
|
---|
1295 | CHECK_DBL(RT_NOCRT(rint)( +42.5), +42.0);
|
---|
1296 | CHECK_DBL(RT_NOCRT(rint)( -43.5), -44.0);
|
---|
1297 | CHECK_DBL(RT_NOCRT(rint)( +43.5), +44.0);
|
---|
1298 | CHECK_DBL(RT_NOCRT(rint)(-42.25), -42.0);
|
---|
1299 | CHECK_DBL(RT_NOCRT(rint)(+42.25), +42.0);
|
---|
1300 | CHECK_DBL(RT_NOCRT(rint)(-42.75), -43.0);
|
---|
1301 | CHECK_DBL(RT_NOCRT(rint)(+42.75), +43.0);
|
---|
1302 | CHECK_DBL_SAME(rint,( -0.0));
|
---|
1303 | CHECK_DBL_SAME(rint,( +0.0));
|
---|
1304 | CHECK_DBL_SAME(rint,( +42.25));
|
---|
1305 | CHECK_DBL_SAME(rint,( +42.50));
|
---|
1306 | CHECK_DBL_SAME(rint,( +42.75));
|
---|
1307 | CHECK_DBL_SAME(rint,( -42.25));
|
---|
1308 | CHECK_DBL_SAME(rint,( -42.50));
|
---|
1309 | CHECK_DBL_SAME(rint,( -42.75));
|
---|
1310 | CHECK_DBL_SAME(rint,(+1234.60958634e+10));
|
---|
1311 | CHECK_DBL_SAME(rint,(-1234.60958634e+10));
|
---|
1312 | CHECK_DBL_SAME(rint,( -1234.499999e+10));
|
---|
1313 | CHECK_DBL_SAME(rint,( -1234.499999e-10));
|
---|
1314 | CHECK_DBL_SAME(rint,( -2.1984e-310)); /* subnormal */
|
---|
1315 | CHECK_DBL_SAME(rint,(-INFINITY));
|
---|
1316 | CHECK_DBL_SAME(rint,(+INFINITY));
|
---|
1317 | CHECK_DBL_SAME(rint,(RTStrNanDouble(NULL, true)));
|
---|
1318 | CHECK_DBL_SAME(rint,(RTStrNanDouble("s", false)));
|
---|
1319 |
|
---|
1320 | CHECK_DBL(RT_NOCRT(rintf)( +0.0f), +0.0f);
|
---|
1321 | CHECK_DBL(RT_NOCRT(rintf)( -0.0f), -0.0f);
|
---|
1322 | CHECK_DBL(RT_NOCRT(rintf)( -42.0f), -42.0f);
|
---|
1323 | CHECK_DBL(RT_NOCRT(rintf)( -42.5f), -42.0f);
|
---|
1324 | CHECK_DBL(RT_NOCRT(rintf)( +42.5f), +42.0f);
|
---|
1325 | CHECK_DBL(RT_NOCRT(rintf)( -43.5f), -44.0f);
|
---|
1326 | CHECK_DBL(RT_NOCRT(rintf)( +43.5f), +44.0f);
|
---|
1327 | CHECK_DBL(RT_NOCRT(rintf)(-42.25f), -42.0f);
|
---|
1328 | CHECK_DBL(RT_NOCRT(rintf)(+42.25f), +42.0f);
|
---|
1329 | CHECK_DBL_SAME(rintf,( -0.0f));
|
---|
1330 | CHECK_DBL_SAME(rintf,( +0.0f));
|
---|
1331 | CHECK_DBL_SAME(rintf,( +42.25f));
|
---|
1332 | CHECK_DBL_SAME(rintf,( +42.50f));
|
---|
1333 | CHECK_DBL_SAME(rintf,( +42.75f));
|
---|
1334 | CHECK_DBL_SAME(rintf,( -42.25f));
|
---|
1335 | CHECK_DBL_SAME(rintf,( -42.50f));
|
---|
1336 | CHECK_DBL_SAME(rintf,( -42.75f));
|
---|
1337 | CHECK_DBL_SAME(rintf,(+1234.60958634e+10f));
|
---|
1338 | CHECK_DBL_SAME(rintf,(-1234.60958634e+10f));
|
---|
1339 | CHECK_DBL_SAME(rintf,( -1234.499999e+10f));
|
---|
1340 | CHECK_DBL_SAME(rintf,( -1234.499999e-10f));
|
---|
1341 | CHECK_DBL_SAME(rintf,( -2.1984e-40f)); /* subnormal */
|
---|
1342 | CHECK_DBL_SAME(rintf,(-INFINITY));
|
---|
1343 | CHECK_DBL_SAME(rintf,(+INFINITY));
|
---|
1344 | CHECK_DBL_SAME(rintf,(RTStrNanFloat(NULL, true)));
|
---|
1345 | CHECK_DBL_SAME(rintf,(RTStrNanFloat("s", false)));
|
---|
1346 |
|
---|
1347 | /*
|
---|
1348 | * Round UP.
|
---|
1349 | */
|
---|
1350 | RT_NOCRT(fesetround)(FE_UPWARD);
|
---|
1351 |
|
---|
1352 | CHECK_DBL(RT_NOCRT(rint)( +0.0), +0.0);
|
---|
1353 | CHECK_DBL(RT_NOCRT(rint)( -0.0), -0.0);
|
---|
1354 | CHECK_DBL(RT_NOCRT(rint)( -42.0), -42.0);
|
---|
1355 | CHECK_DBL(RT_NOCRT(rint)( -42.5), -42.0);
|
---|
1356 | CHECK_DBL(RT_NOCRT(rint)( +42.5), +43.0);
|
---|
1357 | CHECK_DBL(RT_NOCRT(rint)( -43.5), -43.0);
|
---|
1358 | CHECK_DBL(RT_NOCRT(rint)( +43.5), +44.0);
|
---|
1359 | CHECK_DBL(RT_NOCRT(rint)(-42.25), -42.0);
|
---|
1360 | CHECK_DBL(RT_NOCRT(rint)(+42.25), +43.0);
|
---|
1361 | CHECK_DBL(RT_NOCRT(rint)(-42.75), -42.0);
|
---|
1362 | CHECK_DBL(RT_NOCRT(rint)(+42.75), +43.0);
|
---|
1363 | CHECK_DBL_SAME(rint,( -0.0));
|
---|
1364 | CHECK_DBL_SAME(rint,( +0.0));
|
---|
1365 | CHECK_DBL_SAME(rint,( +42.25));
|
---|
1366 | CHECK_DBL_SAME(rint,( +42.50));
|
---|
1367 | CHECK_DBL_SAME(rint,( +42.75));
|
---|
1368 | CHECK_DBL_SAME(rint,( -42.25));
|
---|
1369 | CHECK_DBL_SAME(rint,( -42.50));
|
---|
1370 | CHECK_DBL_SAME(rint,( -42.75));
|
---|
1371 | CHECK_DBL_SAME(rint,(+1234.60958634e+10));
|
---|
1372 | CHECK_DBL_SAME(rint,(-1234.60958634e+10));
|
---|
1373 | CHECK_DBL_SAME(rint,( -1234.499999e+10));
|
---|
1374 | CHECK_DBL_SAME(rint,( -1234.499999e-10));
|
---|
1375 | CHECK_DBL_SAME(rint,( -2.1984e-310)); /* subnormal */
|
---|
1376 | CHECK_DBL_SAME(rint,(-INFINITY));
|
---|
1377 | CHECK_DBL_SAME(rint,(+INFINITY));
|
---|
1378 | CHECK_DBL_SAME(rint,(RTStrNanDouble(NULL, true)));
|
---|
1379 | CHECK_DBL_SAME(rint,(RTStrNanDouble("s", false)));
|
---|
1380 |
|
---|
1381 | CHECK_DBL(RT_NOCRT(rintf)( +0.0f), +0.0f);
|
---|
1382 | CHECK_DBL(RT_NOCRT(rintf)( -0.0f), -0.0f);
|
---|
1383 | CHECK_DBL(RT_NOCRT(rintf)( -42.0f), -42.0f);
|
---|
1384 | CHECK_DBL(RT_NOCRT(rintf)( -42.5f), -42.0f);
|
---|
1385 | CHECK_DBL(RT_NOCRT(rintf)( +42.5f), +43.0f);
|
---|
1386 | CHECK_DBL(RT_NOCRT(rintf)( -43.5f), -43.0f);
|
---|
1387 | CHECK_DBL(RT_NOCRT(rintf)( +43.5f), +44.0f);
|
---|
1388 | CHECK_DBL(RT_NOCRT(rintf)(-42.25f), -42.0f);
|
---|
1389 | CHECK_DBL(RT_NOCRT(rintf)(+42.25f), +43.0f);
|
---|
1390 | CHECK_DBL_SAME(rintf,( -0.0f));
|
---|
1391 | CHECK_DBL_SAME(rintf,( +0.0f));
|
---|
1392 | CHECK_DBL_SAME(rintf,( +42.25f));
|
---|
1393 | CHECK_DBL_SAME(rintf,( +42.50f));
|
---|
1394 | CHECK_DBL_SAME(rintf,( +42.75f));
|
---|
1395 | CHECK_DBL_SAME(rintf,( -42.25f));
|
---|
1396 | CHECK_DBL_SAME(rintf,( -42.50f));
|
---|
1397 | CHECK_DBL_SAME(rintf,( -42.75f));
|
---|
1398 | CHECK_DBL_SAME(rintf,(+1234.60958634e+10f));
|
---|
1399 | CHECK_DBL_SAME(rintf,(-1234.60958634e+10f));
|
---|
1400 | CHECK_DBL_SAME(rintf,( -1234.499999e+10f));
|
---|
1401 | CHECK_DBL_SAME(rintf,( -1234.499999e-10f));
|
---|
1402 | CHECK_DBL_SAME(rintf,( -2.1984e-40f)); /* subnormal */
|
---|
1403 | CHECK_DBL_SAME(rintf,(-INFINITY));
|
---|
1404 | CHECK_DBL_SAME(rintf,(+INFINITY));
|
---|
1405 | CHECK_DBL_SAME(rintf,(RTStrNanFloat(NULL, true)));
|
---|
1406 | CHECK_DBL_SAME(rintf,(RTStrNanFloat("s", false)));
|
---|
1407 |
|
---|
1408 | /*
|
---|
1409 | * Round DOWN.
|
---|
1410 | */
|
---|
1411 | RT_NOCRT(fesetround)(FE_DOWNWARD);
|
---|
1412 |
|
---|
1413 | CHECK_DBL(RT_NOCRT(rint)( +0.0), +0.0);
|
---|
1414 | CHECK_DBL(RT_NOCRT(rint)( -0.0), -0.0);
|
---|
1415 | CHECK_DBL(RT_NOCRT(rint)( -42.0), -42.0);
|
---|
1416 | CHECK_DBL(RT_NOCRT(rint)( -42.5), -43.0);
|
---|
1417 | CHECK_DBL(RT_NOCRT(rint)( +42.5), +42.0);
|
---|
1418 | CHECK_DBL(RT_NOCRT(rint)( -43.5), -44.0);
|
---|
1419 | CHECK_DBL(RT_NOCRT(rint)( +43.5), +43.0);
|
---|
1420 | CHECK_DBL(RT_NOCRT(rint)(-42.25), -43.0);
|
---|
1421 | CHECK_DBL(RT_NOCRT(rint)(+42.25), +42.0);
|
---|
1422 | CHECK_DBL(RT_NOCRT(rint)(-42.75), -43.0);
|
---|
1423 | CHECK_DBL(RT_NOCRT(rint)(+42.75), +42.0);
|
---|
1424 | CHECK_DBL_SAME(rint,( -0.0));
|
---|
1425 | CHECK_DBL_SAME(rint,( +0.0));
|
---|
1426 | CHECK_DBL_SAME(rint,( +42.25));
|
---|
1427 | CHECK_DBL_SAME(rint,( +42.50));
|
---|
1428 | CHECK_DBL_SAME(rint,( +42.75));
|
---|
1429 | CHECK_DBL_SAME(rint,( -42.25));
|
---|
1430 | CHECK_DBL_SAME(rint,( -42.50));
|
---|
1431 | CHECK_DBL_SAME(rint,( -42.75));
|
---|
1432 | CHECK_DBL_SAME(rint,(+1234.60958634e+10));
|
---|
1433 | CHECK_DBL_SAME(rint,(-1234.60958634e+10));
|
---|
1434 | CHECK_DBL_SAME(rint,( -1234.499999e+10));
|
---|
1435 | CHECK_DBL_SAME(rint,( -1234.499999e-10));
|
---|
1436 | CHECK_DBL_SAME(rint,( -2.1984e-310)); /* subnormal */
|
---|
1437 | CHECK_DBL_SAME(rint,(-INFINITY));
|
---|
1438 | CHECK_DBL_SAME(rint,(+INFINITY));
|
---|
1439 | CHECK_DBL_SAME(rint,(RTStrNanDouble(NULL, true)));
|
---|
1440 | CHECK_DBL_SAME(rint,(RTStrNanDouble("s", false)));
|
---|
1441 |
|
---|
1442 | CHECK_DBL(RT_NOCRT(rintf)( +0.0f), +0.0f);
|
---|
1443 | CHECK_DBL(RT_NOCRT(rintf)( -0.0f), -0.0f);
|
---|
1444 | CHECK_DBL(RT_NOCRT(rintf)( -42.0f), -42.0f);
|
---|
1445 | CHECK_DBL(RT_NOCRT(rintf)( -42.5f), -43.0f);
|
---|
1446 | CHECK_DBL(RT_NOCRT(rintf)( +42.5f), +42.0f);
|
---|
1447 | CHECK_DBL(RT_NOCRT(rintf)( -43.5f), -44.0f);
|
---|
1448 | CHECK_DBL(RT_NOCRT(rintf)( +43.5f), +43.0f);
|
---|
1449 | CHECK_DBL(RT_NOCRT(rintf)(-42.25f), -43.0f);
|
---|
1450 | CHECK_DBL(RT_NOCRT(rintf)(+42.25f), +42.0f);
|
---|
1451 | CHECK_DBL_SAME(rintf,( -0.0f));
|
---|
1452 | CHECK_DBL_SAME(rintf,( +0.0f));
|
---|
1453 | CHECK_DBL_SAME(rintf,( +42.25f));
|
---|
1454 | CHECK_DBL_SAME(rintf,( +42.50f));
|
---|
1455 | CHECK_DBL_SAME(rintf,( +42.75f));
|
---|
1456 | CHECK_DBL_SAME(rintf,( -42.25f));
|
---|
1457 | CHECK_DBL_SAME(rintf,( -42.50f));
|
---|
1458 | CHECK_DBL_SAME(rintf,( -42.75f));
|
---|
1459 | CHECK_DBL_SAME(rintf,(+1234.60958634e+10f));
|
---|
1460 | CHECK_DBL_SAME(rintf,(-1234.60958634e+10f));
|
---|
1461 | CHECK_DBL_SAME(rintf,( -1234.499999e+10f));
|
---|
1462 | CHECK_DBL_SAME(rintf,( -1234.499999e-10f));
|
---|
1463 | CHECK_DBL_SAME(rintf,( -2.1984e-40f)); /* subnormal */
|
---|
1464 | CHECK_DBL_SAME(rintf,(-INFINITY));
|
---|
1465 | CHECK_DBL_SAME(rintf,(+INFINITY));
|
---|
1466 | CHECK_DBL_SAME(rintf,(RTStrNanFloat(NULL, true)));
|
---|
1467 | CHECK_DBL_SAME(rintf,(RTStrNanFloat("s", false)));
|
---|
1468 |
|
---|
1469 | /*
|
---|
1470 | * Round towards ZERO.
|
---|
1471 | */
|
---|
1472 | RT_NOCRT(fesetround)(FE_TOWARDZERO);
|
---|
1473 |
|
---|
1474 | CHECK_DBL(RT_NOCRT(rint)( +0.0), +0.0);
|
---|
1475 | CHECK_DBL(RT_NOCRT(rint)( -0.0), -0.0);
|
---|
1476 | CHECK_DBL(RT_NOCRT(rint)( -42.0), -42.0);
|
---|
1477 | CHECK_DBL(RT_NOCRT(rint)( -42.5), -42.0);
|
---|
1478 | CHECK_DBL(RT_NOCRT(rint)( +42.5), +42.0);
|
---|
1479 | CHECK_DBL(RT_NOCRT(rint)( -43.5), -43.0);
|
---|
1480 | CHECK_DBL(RT_NOCRT(rint)( +43.5), +43.0);
|
---|
1481 | CHECK_DBL(RT_NOCRT(rint)(-42.25), -42.0);
|
---|
1482 | CHECK_DBL(RT_NOCRT(rint)(+42.25), +42.0);
|
---|
1483 | CHECK_DBL(RT_NOCRT(rint)(-42.75), -42.0);
|
---|
1484 | CHECK_DBL(RT_NOCRT(rint)(+42.75), +42.0);
|
---|
1485 | CHECK_DBL_SAME(rint,( -0.0));
|
---|
1486 | CHECK_DBL_SAME(rint,( +0.0));
|
---|
1487 | CHECK_DBL_SAME(rint,( +42.25));
|
---|
1488 | CHECK_DBL_SAME(rint,( +42.50));
|
---|
1489 | CHECK_DBL_SAME(rint,( +42.75));
|
---|
1490 | CHECK_DBL_SAME(rint,( -42.25));
|
---|
1491 | CHECK_DBL_SAME(rint,( -42.50));
|
---|
1492 | CHECK_DBL_SAME(rint,( -42.75));
|
---|
1493 | CHECK_DBL_SAME(rint,(+1234.60958634e+10));
|
---|
1494 | CHECK_DBL_SAME(rint,(-1234.60958634e+10));
|
---|
1495 | CHECK_DBL_SAME(rint,( -1234.499999e+10));
|
---|
1496 | CHECK_DBL_SAME(rint,( -1234.499999e-10));
|
---|
1497 | CHECK_DBL_SAME(rint,( -2.1984e-310)); /* subnormal */
|
---|
1498 | CHECK_DBL_SAME(rint,(-INFINITY));
|
---|
1499 | CHECK_DBL_SAME(rint,(+INFINITY));
|
---|
1500 | CHECK_DBL_SAME(rint,(RTStrNanDouble(NULL, true)));
|
---|
1501 | CHECK_DBL_SAME(rint,(RTStrNanDouble("s", false)));
|
---|
1502 |
|
---|
1503 | CHECK_DBL(RT_NOCRT(rintf)( +0.0f), +0.0f);
|
---|
1504 | CHECK_DBL(RT_NOCRT(rintf)( -0.0f), -0.0f);
|
---|
1505 | CHECK_DBL(RT_NOCRT(rintf)( -42.0f), -42.0f);
|
---|
1506 | CHECK_DBL(RT_NOCRT(rintf)( -42.5f), -42.0f);
|
---|
1507 | CHECK_DBL(RT_NOCRT(rintf)( +42.5f), +42.0f);
|
---|
1508 | CHECK_DBL(RT_NOCRT(rintf)( -43.5f), -43.0f);
|
---|
1509 | CHECK_DBL(RT_NOCRT(rintf)( +43.5f), +43.0f);
|
---|
1510 | CHECK_DBL(RT_NOCRT(rintf)(-42.25f), -42.0f);
|
---|
1511 | CHECK_DBL(RT_NOCRT(rintf)(+42.25f), +42.0f);
|
---|
1512 | CHECK_DBL_SAME(rintf,( -0.0f));
|
---|
1513 | CHECK_DBL_SAME(rintf,( +0.0f));
|
---|
1514 | CHECK_DBL_SAME(rintf,( +42.25f));
|
---|
1515 | CHECK_DBL_SAME(rintf,( +42.50f));
|
---|
1516 | CHECK_DBL_SAME(rintf,( +42.75f));
|
---|
1517 | CHECK_DBL_SAME(rintf,( -42.25f));
|
---|
1518 | CHECK_DBL_SAME(rintf,( -42.50f));
|
---|
1519 | CHECK_DBL_SAME(rintf,( -42.75f));
|
---|
1520 | CHECK_DBL_SAME(rintf,(+1234.60958634e+10f));
|
---|
1521 | CHECK_DBL_SAME(rintf,(-1234.60958634e+10f));
|
---|
1522 | CHECK_DBL_SAME(rintf,( -1234.499999e+10f));
|
---|
1523 | CHECK_DBL_SAME(rintf,( -1234.499999e-10f));
|
---|
1524 | CHECK_DBL_SAME(rintf,( -2.1984e-40f)); /* subnormal */
|
---|
1525 | CHECK_DBL_SAME(rintf,(-INFINITY));
|
---|
1526 | CHECK_DBL_SAME(rintf,(+INFINITY));
|
---|
1527 | CHECK_DBL_SAME(rintf,(RTStrNanFloat(NULL, true)));
|
---|
1528 | CHECK_DBL_SAME(rintf,(RTStrNanFloat("s", false)));
|
---|
1529 |
|
---|
1530 | RT_NOCRT(fesetround)(iSavedMode);
|
---|
1531 | }
|
---|
1532 |
|
---|
1533 |
|
---|
1534 | void testLRound()
|
---|
1535 | {
|
---|
1536 | RTTestSub(g_hTest, "lround[f]");
|
---|
1537 | CHECK_LONG(RT_NOCRT(lround)( +0.0), 0);
|
---|
1538 | CHECK_LONG(RT_NOCRT(lround)( -0.0), 0);
|
---|
1539 | CHECK_LONG(RT_NOCRT(lround)( -42.0), -42);
|
---|
1540 | CHECK_LONG(RT_NOCRT(lround)( -42.5), -43);
|
---|
1541 | CHECK_LONG(RT_NOCRT(lround)( +42.5), +43);
|
---|
1542 | CHECK_LONG(RT_NOCRT(lround)( -42.25), -42);
|
---|
1543 | CHECK_LONG(RT_NOCRT(lround)( +42.25), +42);
|
---|
1544 | CHECK_LONG(RT_NOCRT(lround)(+1234.60958634e+20), LONG_MAX);
|
---|
1545 | CHECK_LONG(RT_NOCRT(lround)(-1234.60958634e+20), LONG_MIN);
|
---|
1546 | CHECK_LONG(RT_NOCRT(lround)( -1234.499999e+20), LONG_MIN);
|
---|
1547 | CHECK_LONG(RT_NOCRT(lround)( -1234.499999e-10), 0);
|
---|
1548 | CHECK_LONG(RT_NOCRT(lround)( -2.1984e-310), 0); /* subnormal */
|
---|
1549 | CHECK_LONG(RT_NOCRT(lround)(-INFINITY), LONG_MIN);
|
---|
1550 | CHECK_LONG(RT_NOCRT(lround)(+INFINITY), LONG_MAX);
|
---|
1551 | CHECK_LONG(RT_NOCRT(lround)(RTStrNanDouble(NULL, true)), LONG_MAX);
|
---|
1552 | CHECK_LONG(RT_NOCRT(lround)(RTStrNanDouble("s", false)), LONG_MAX);
|
---|
1553 | CHECK_LONG_SAME(lround,( -0.0));
|
---|
1554 | CHECK_LONG_SAME(lround,( +0.0));
|
---|
1555 | CHECK_LONG_SAME(lround,( +42.25));
|
---|
1556 | CHECK_LONG_SAME(lround,( +42.25e+6));
|
---|
1557 | CHECK_LONG_SAME(lround,( -42.25e+6));
|
---|
1558 | CHECK_LONG_SAME(lround,( -1234.499999e-10));
|
---|
1559 | CHECK_LONG_SAME(lround,( -2.1984e-310)); /* subnormal */
|
---|
1560 | #if 0 /* unspecified, we test our expected behavior above */
|
---|
1561 | CHECK_LONG_SAME(lround,(+1234.60958634e+20));
|
---|
1562 | CHECK_LONG_SAME(lround,(-1234.60958634e+20));
|
---|
1563 | CHECK_LONG_SAME(lround,( -1234.499999e+20));
|
---|
1564 | CHECK_LONG_SAME(lround,(-INFINITY));
|
---|
1565 | CHECK_LONG_SAME(lround,(+INFINITY));
|
---|
1566 | CHECK_LONG_SAME(lround,(RTStrNanDouble(NULL, true)));
|
---|
1567 | CHECK_LONG_SAME(lround,(RTStrNanDouble("s", false)));
|
---|
1568 | #endif
|
---|
1569 |
|
---|
1570 | CHECK_LONG(RT_NOCRT(lroundf)( +0.0f), 0);
|
---|
1571 | CHECK_LONG(RT_NOCRT(lroundf)( -0.0f), 0);
|
---|
1572 | CHECK_LONG(RT_NOCRT(lroundf)( -42.0f), -42);
|
---|
1573 | CHECK_LONG(RT_NOCRT(lroundf)( -42.5f), -43);
|
---|
1574 | CHECK_LONG(RT_NOCRT(lroundf)( +42.5f), +43);
|
---|
1575 | CHECK_LONG(RT_NOCRT(lroundf)( -42.25f), -42);
|
---|
1576 | CHECK_LONG(RT_NOCRT(lroundf)( +42.25f), +42);
|
---|
1577 | CHECK_LONG(RT_NOCRT(lroundf)(+1234.60958634e+20f), LONG_MAX);
|
---|
1578 | CHECK_LONG(RT_NOCRT(lroundf)(-1234.60958634e+20f), LONG_MIN);
|
---|
1579 | CHECK_LONG(RT_NOCRT(lroundf)( -1234.499999e+20f), LONG_MIN);
|
---|
1580 | CHECK_LONG(RT_NOCRT(lroundf)( -1234.499999e-10f), 0);
|
---|
1581 | CHECK_LONG(RT_NOCRT(lroundf)( -2.1984e-40f), 0); /* subnormal */
|
---|
1582 | CHECK_LONG(RT_NOCRT(lroundf)(-INFINITY), LONG_MIN);
|
---|
1583 | CHECK_LONG(RT_NOCRT(lroundf)(+INFINITY), LONG_MAX);
|
---|
1584 | CHECK_LONG(RT_NOCRT(lroundf)(RTStrNanFloat(NULL, true)), LONG_MAX);
|
---|
1585 | CHECK_LONG(RT_NOCRT(lroundf)(RTStrNanFloat("s", false)), LONG_MAX);
|
---|
1586 | CHECK_LONG_SAME(lroundf,( -0.0f));
|
---|
1587 | CHECK_LONG_SAME(lroundf,( +0.0f));
|
---|
1588 | CHECK_LONG_SAME(lroundf,( +42.25f));
|
---|
1589 | CHECK_LONG_SAME(lroundf,( +42.25e+6f));
|
---|
1590 | CHECK_LONG_SAME(lroundf,( -42.25e+6f));
|
---|
1591 | CHECK_LONG_SAME(lroundf,( -1234.499999e-10f));
|
---|
1592 | CHECK_LONG_SAME(lroundf,( -2.1984e-40f)); /* subnormal */
|
---|
1593 | #if 0 /* unspecified, we test our expected behavior above */
|
---|
1594 | CHECK_LONG_SAME(lroundf,(+1234.60958634e+20f));
|
---|
1595 | CHECK_LONG_SAME(lroundf,(-1234.60958634e+20f));
|
---|
1596 | CHECK_LONG_SAME(lroundf,( -1234.499999e+20f));
|
---|
1597 | CHECK_LONG_SAME(lroundf,(-INFINITY));
|
---|
1598 | CHECK_LONG_SAME(lroundf,(+INFINITY));
|
---|
1599 | CHECK_LONG_SAME(lroundf,(RTStrNanFloat(NULL, true)));
|
---|
1600 | CHECK_LONG_SAME(lroundf,(RTStrNanFloat("s", false)));
|
---|
1601 | #endif
|
---|
1602 | }
|
---|
1603 |
|
---|
1604 |
|
---|
1605 | void testLLRound()
|
---|
1606 | {
|
---|
1607 | RTTestSub(g_hTest, "llround[f]");
|
---|
1608 | CHECK_LLONG(RT_NOCRT(llround)( +0.0), 0);
|
---|
1609 | CHECK_LLONG(RT_NOCRT(llround)( -0.0), 0);
|
---|
1610 | CHECK_LLONG(RT_NOCRT(llround)( -42.0), -42);
|
---|
1611 | CHECK_LLONG(RT_NOCRT(llround)( -42.5), -43);
|
---|
1612 | CHECK_LLONG(RT_NOCRT(llround)( +42.5), +43);
|
---|
1613 | CHECK_LLONG(RT_NOCRT(llround)(-42.25), -42);
|
---|
1614 | CHECK_LLONG(RT_NOCRT(llround)(+42.25), +42);
|
---|
1615 | CHECK_LLONG(RT_NOCRT(llround)(+42.25e4), +422500);
|
---|
1616 | CHECK_LLONG(RT_NOCRT(llround)(+42.25e12), +42250000000000LL);
|
---|
1617 | CHECK_LLONG(RT_NOCRT(llround)(+1234.60958634e+20), LLONG_MAX);
|
---|
1618 | CHECK_LLONG(RT_NOCRT(llround)(-1234.60958634e+20), LLONG_MIN);
|
---|
1619 | CHECK_LLONG(RT_NOCRT(llround)( -1234.499999e+20), LLONG_MIN);
|
---|
1620 | CHECK_LLONG(RT_NOCRT(llround)( -1234.499999e-10), 0);
|
---|
1621 | CHECK_LLONG(RT_NOCRT(llround)( -2.1984e-310), 0); /* subnormal */
|
---|
1622 | CHECK_LLONG(RT_NOCRT(llround)(-INFINITY), LLONG_MIN);
|
---|
1623 | CHECK_LLONG(RT_NOCRT(llround)(+INFINITY), LLONG_MAX);
|
---|
1624 | CHECK_LLONG(RT_NOCRT(llround)(RTStrNanDouble(NULL, true)), LLONG_MAX);
|
---|
1625 | CHECK_LLONG(RT_NOCRT(llround)(RTStrNanDouble("s", false)), LLONG_MAX);
|
---|
1626 | CHECK_LLONG_SAME(llround,( -0.0));
|
---|
1627 | CHECK_LLONG_SAME(llround,( +0.0));
|
---|
1628 | CHECK_LLONG_SAME(llround,( +42.25));
|
---|
1629 | CHECK_LLONG_SAME(llround,( +42.25e+6));
|
---|
1630 | CHECK_LLONG_SAME(llround,( -42.25e+6));
|
---|
1631 | CHECK_LLONG_SAME(llround,( -42.25e+12));
|
---|
1632 | CHECK_LLONG_SAME(llround,( +42.265785e+13));
|
---|
1633 | CHECK_LLONG_SAME(llround,( -1234.499999e-10));
|
---|
1634 | CHECK_LLONG_SAME(llround,( -2.1984e-310)); /* subnormal */
|
---|
1635 | #if 0 /* unspecified, we test our expected behavior above */
|
---|
1636 | CHECK_LLONG_SAME(llround,(+1234.60958634e+20));
|
---|
1637 | CHECK_LLONG_SAME(llround,(-1234.60958634e+20));
|
---|
1638 | CHECK_LLONG_SAME(llround,( -1234.499999e+20));
|
---|
1639 | CHECK_LLONG_SAME(llround,(-INFINITY));
|
---|
1640 | CHECK_LLONG_SAME(llround,(+INFINITY));
|
---|
1641 | CHECK_LLONG_SAME(llround,(RTStrNanDouble(NULL, true)));
|
---|
1642 | CHECK_LLONG_SAME(llround,(RTStrNanDouble("s", false)));
|
---|
1643 | #endif
|
---|
1644 |
|
---|
1645 | CHECK_LLONG(RT_NOCRT(llroundf)( +0.0f), 0);
|
---|
1646 | CHECK_LLONG(RT_NOCRT(llroundf)( -0.0f), 0);
|
---|
1647 | CHECK_LLONG(RT_NOCRT(llroundf)( -42.0f), -42);
|
---|
1648 | CHECK_LLONG(RT_NOCRT(llroundf)( -42.5f), -43);
|
---|
1649 | CHECK_LLONG(RT_NOCRT(llroundf)( +42.5f), +43);
|
---|
1650 | CHECK_LLONG(RT_NOCRT(llroundf)(-42.25f), -42);
|
---|
1651 | CHECK_LLONG(RT_NOCRT(llroundf)(+42.25f), +42);
|
---|
1652 | CHECK_LLONG(RT_NOCRT(llroundf)(+42.25e4f), +422500);
|
---|
1653 | CHECK_LLONG(RT_NOCRT(llroundf)(+42.24e10f), +422400000000LL);
|
---|
1654 | CHECK_LLONG(RT_NOCRT(llroundf)(+1234.60958634e+20f), LLONG_MAX);
|
---|
1655 | CHECK_LLONG(RT_NOCRT(llroundf)(-1234.60958634e+20f), LLONG_MIN);
|
---|
1656 | CHECK_LLONG(RT_NOCRT(llroundf)( -1234.499999e+20f), LLONG_MIN);
|
---|
1657 | CHECK_LLONG(RT_NOCRT(llroundf)( -1234.499999e-10f), 0);
|
---|
1658 | CHECK_LLONG(RT_NOCRT(llroundf)( -2.1984e-40f), 0); /* subnormal */
|
---|
1659 | CHECK_LLONG(RT_NOCRT(llroundf)(-INFINITY), LLONG_MIN);
|
---|
1660 | CHECK_LLONG(RT_NOCRT(llroundf)(+INFINITY), LLONG_MAX);
|
---|
1661 | CHECK_LLONG(RT_NOCRT(llroundf)(RTStrNanFloat(NULL, true)), LLONG_MAX);
|
---|
1662 | CHECK_LLONG(RT_NOCRT(llroundf)(RTStrNanFloat("s", false)), LLONG_MAX);
|
---|
1663 | CHECK_LLONG_SAME(llroundf,( -0.0f));
|
---|
1664 | CHECK_LLONG_SAME(llroundf,( +0.0f));
|
---|
1665 | CHECK_LLONG_SAME(llroundf,( +42.25f));
|
---|
1666 | CHECK_LLONG_SAME(llroundf,( +42.25e+6f));
|
---|
1667 | CHECK_LLONG_SAME(llroundf,( -42.25e+6f));
|
---|
1668 | CHECK_LLONG_SAME(llroundf,( -42.25e+12f));
|
---|
1669 | CHECK_LLONG_SAME(llroundf,( +42.265785e+13f));
|
---|
1670 | CHECK_LLONG_SAME(llroundf,( -1234.499999e-10f));
|
---|
1671 | CHECK_LLONG_SAME(llroundf,( -2.1984e-40f)); /* subnormal */
|
---|
1672 | #if 0 /* unspecified, we test our expected behavior above */
|
---|
1673 | CHECK_LLONG_SAME(llroundf,(+1234.60958634e+20f));
|
---|
1674 | CHECK_LLONG_SAME(llroundf,(-1234.60958634e+20f));
|
---|
1675 | CHECK_LLONG_SAME(llroundf,( -1234.499999e+20f));
|
---|
1676 | CHECK_LLONG_SAME(llroundf,(-INFINITY));
|
---|
1677 | CHECK_LLONG_SAME(llroundf,(+INFINITY));
|
---|
1678 | CHECK_LLONG_SAME(llroundf,(RTStrNanFloat(NULL, true)));
|
---|
1679 | CHECK_LLONG_SAME(llroundf,(RTStrNanFloat("s", false)));
|
---|
1680 | #endif
|
---|
1681 |
|
---|
1682 | #if 0
|
---|
1683 | CHECK_LLONG(RT_NOCRT(llroundl)( +0.0L), 0);
|
---|
1684 | CHECK_LLONG(RT_NOCRT(llroundl)( -0.0L), 0);
|
---|
1685 | CHECK_LLONG(RT_NOCRT(llroundl)( -42.0L), -42);
|
---|
1686 | CHECK_LLONG(RT_NOCRT(llroundl)( -42.5L), -43);
|
---|
1687 | CHECK_LLONG(RT_NOCRT(llroundl)( +42.5L), +43);
|
---|
1688 | CHECK_LLONG(RT_NOCRT(llroundl)(-42.25L), -42);
|
---|
1689 | CHECK_LLONG(RT_NOCRT(llroundl)(+42.25L), +42);
|
---|
1690 | CHECK_LLONG(RT_NOCRT(llroundl)(+42.25e4L), +422500);
|
---|
1691 | CHECK_LLONG(RT_NOCRT(llroundl)(+42.24e12L), +42240000000000LL);
|
---|
1692 | CHECK_LLONG(RT_NOCRT(llroundl)(+1234.60958634e+20L), LLONG_MAX);
|
---|
1693 | CHECK_LLONG(RT_NOCRT(llroundl)(-1234.60958634e+20L), LLONG_MIN);
|
---|
1694 | CHECK_LLONG(RT_NOCRT(llroundl)( -1234.499999e+20L), LLONG_MIN);
|
---|
1695 | CHECK_LLONG(RT_NOCRT(llroundl)( -1234.499999e-10L), 0);
|
---|
1696 | #ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
1697 | CHECK_LLONG(RT_NOCRT(llroundl)( -2.1984e-310L), 0); /* subnormal */
|
---|
1698 | #else
|
---|
1699 | CHECK_LLONG(RT_NOCRT(llroundl)( -2.1984e-4935L), 0); /* subnormal */
|
---|
1700 | #endif
|
---|
1701 | CHECK_LLONG(RT_NOCRT(llroundl)(-INFINITY), LLONG_MIN);
|
---|
1702 | CHECK_LLONG(RT_NOCRT(llroundl)(+INFINITY), LLONG_MAX);
|
---|
1703 | CHECK_LLONG(RT_NOCRT(llroundl)(RTStrNanLongDouble(NULL, true)), LLONG_MAX);
|
---|
1704 | CHECK_LLONG(RT_NOCRT(llroundl)(RTStrNanLongDouble("s", false)), LLONG_MAX);
|
---|
1705 | CHECK_LLONG_SAME(llroundl,( -0.0));
|
---|
1706 | CHECK_LLONG_SAME(llroundl,( +0.0));
|
---|
1707 | CHECK_LLONG_SAME(llroundl,( +42.25));
|
---|
1708 | CHECK_LLONG_SAME(llroundl,( +42.25e+6));
|
---|
1709 | CHECK_LLONG_SAME(llroundl,( -42.25e+6));
|
---|
1710 | CHECK_LLONG_SAME(llroundl,( -42.25e+12));
|
---|
1711 | CHECK_LLONG_SAME(llroundl,( +42.265785e+13));
|
---|
1712 | CHECK_LLONG_SAME(llroundl,( -1234.499999e-10L));
|
---|
1713 | # ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
|
---|
1714 | CHECK_LLONG_SAME(llroundl,( -2.1984e-310L)); /* subnormal */
|
---|
1715 | # else
|
---|
1716 | CHECK_LLONG_SAME(llroundl,( -2.1984e-4935L)); /* subnormal */
|
---|
1717 | # endif
|
---|
1718 | #if 0 /* unspecified, we test our expected behavior above */
|
---|
1719 | CHECK_LLONG_SAME(llroundl,(+1234.60958634e+20L));
|
---|
1720 | CHECK_LLONG_SAME(llroundl,(-1234.60958634e+20L));
|
---|
1721 | CHECK_LLONG_SAME(llroundl,( -1234.499999e+20L));
|
---|
1722 | CHECK_LLONG_SAME(llroundl,(-INFINITY));
|
---|
1723 | CHECK_LLONG_SAME(llroundl,(+INFINITY));
|
---|
1724 | CHECK_LLONG_SAME(llroundl,(RTStrNanLongDouble(NULL, true)));
|
---|
1725 | CHECK_LLONG_SAME(llroundl,(RTStrNanLongDouble("s", false)));
|
---|
1726 | #endif
|
---|
1727 | #endif
|
---|
1728 | }
|
---|
1729 |
|
---|
1730 |
|
---|
1731 | void testLRInt()
|
---|
1732 | {
|
---|
1733 | RTTestSub(g_hTest, "lrint[f]");
|
---|
1734 |
|
---|
1735 | /*
|
---|
1736 | * Round nearest.
|
---|
1737 | */
|
---|
1738 | int const iSavedMode = RT_NOCRT(fegetround)();
|
---|
1739 | if (iSavedMode != FE_TONEAREST)
|
---|
1740 | RTTestFailed(g_hTest, "expected FE_TONEAREST as default rounding mode, not %#x (%d)", iSavedMode, iSavedMode);
|
---|
1741 | RT_NOCRT(fesetround)(FE_TONEAREST);
|
---|
1742 |
|
---|
1743 | CHECK_LONG(RT_NOCRT(lrint)( +0.0), 0);
|
---|
1744 | CHECK_LONG(RT_NOCRT(lrint)( -0.0), 0);
|
---|
1745 | CHECK_LONG(RT_NOCRT(lrint)( -42.0), -42);
|
---|
1746 | CHECK_LONG(RT_NOCRT(lrint)( -42.5), -42);
|
---|
1747 | CHECK_LONG(RT_NOCRT(lrint)( +42.5), +42);
|
---|
1748 | CHECK_LONG(RT_NOCRT(lrint)( -43.5), -44);
|
---|
1749 | CHECK_LONG(RT_NOCRT(lrint)( +43.5), +44);
|
---|
1750 | CHECK_LONG(RT_NOCRT(lrint)( -42.25), -42);
|
---|
1751 | CHECK_LONG(RT_NOCRT(lrint)( +42.25), +42);
|
---|
1752 | CHECK_LONG(RT_NOCRT(lrint)( -42.75), -43);
|
---|
1753 | CHECK_LONG(RT_NOCRT(lrint)( +42.75), +43);
|
---|
1754 | CHECK_LONG(RT_NOCRT(lrint)(+1234.60958634e+20), LONG_MIN);
|
---|
1755 | CHECK_LONG(RT_NOCRT(lrint)(-1234.60958634e+20), LONG_MIN);
|
---|
1756 | CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e+20), LONG_MIN);
|
---|
1757 | CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e-10), 0);
|
---|
1758 | CHECK_LONG(RT_NOCRT(lrint)( -2.1984e-310), 0); /* subnormal */
|
---|
1759 | CHECK_LONG(RT_NOCRT(lrint)(-INFINITY), LONG_MIN);
|
---|
1760 | CHECK_LONG(RT_NOCRT(lrint)(+INFINITY), LONG_MIN);
|
---|
1761 | CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble(NULL, true)), LONG_MIN);
|
---|
1762 | CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble("s", false)), LONG_MIN);
|
---|
1763 | CHECK_LONG_SAME(lrint,( -0.0));
|
---|
1764 | CHECK_LONG_SAME(lrint,( +0.0));
|
---|
1765 | CHECK_LONG_SAME(lrint,( +42.25));
|
---|
1766 | CHECK_LONG_SAME(lrint,( -42.25));
|
---|
1767 | CHECK_LONG_SAME(lrint,( +42.75));
|
---|
1768 | CHECK_LONG_SAME(lrint,( -42.75));
|
---|
1769 | CHECK_LONG_SAME(lrint,( +22.5));
|
---|
1770 | CHECK_LONG_SAME(lrint,( -22.5));
|
---|
1771 | CHECK_LONG_SAME(lrint,( +23.5));
|
---|
1772 | CHECK_LONG_SAME(lrint,( -23.5));
|
---|
1773 | CHECK_LONG_SAME(lrint,( +42.25e+6));
|
---|
1774 | CHECK_LONG_SAME(lrint,( -42.25e+6));
|
---|
1775 | CHECK_LONG_SAME(lrint,( -1234.499999e-10));
|
---|
1776 | CHECK_LONG_SAME(lrint,( -2.1984e-310)); /* subnormal */
|
---|
1777 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
1778 | CHECK_LONG_SAME(lrint,(+1234.60958634e+20));
|
---|
1779 | CHECK_LONG_SAME(lrint,(-1234.60958634e+20));
|
---|
1780 | CHECK_LONG_SAME(lrint,( -1234.499999e+20));
|
---|
1781 | CHECK_LONG_SAME(lrint,(-INFINITY));
|
---|
1782 | CHECK_LONG_SAME(lrint,(+INFINITY));
|
---|
1783 | CHECK_LONG_SAME(lrint,(RTStrNanDouble(NULL, true)));
|
---|
1784 | CHECK_LONG_SAME(lrint,(RTStrNanDouble("s", false)));
|
---|
1785 | #endif
|
---|
1786 |
|
---|
1787 | CHECK_LONG(RT_NOCRT(lrintf)( +0.0f), 0);
|
---|
1788 | CHECK_LONG(RT_NOCRT(lrintf)( -0.0f), 0);
|
---|
1789 | CHECK_LONG(RT_NOCRT(lrintf)( -42.0f), -42);
|
---|
1790 | CHECK_LONG(RT_NOCRT(lrintf)( -42.5f), -42);
|
---|
1791 | CHECK_LONG(RT_NOCRT(lrintf)( +42.5f), +42);
|
---|
1792 | CHECK_LONG(RT_NOCRT(lrintf)( -43.5f), -44);
|
---|
1793 | CHECK_LONG(RT_NOCRT(lrintf)( +43.5f), +44);
|
---|
1794 | CHECK_LONG(RT_NOCRT(lrintf)( -42.25f), -42);
|
---|
1795 | CHECK_LONG(RT_NOCRT(lrintf)( +42.25f), +42);
|
---|
1796 | CHECK_LONG(RT_NOCRT(lrintf)( -42.75f), -43);
|
---|
1797 | CHECK_LONG(RT_NOCRT(lrintf)( +42.75f), +43);
|
---|
1798 | CHECK_LONG(RT_NOCRT(lrintf)(+1234.60958634e+20f), LONG_MIN);
|
---|
1799 | CHECK_LONG(RT_NOCRT(lrintf)(-1234.60958634e+20f), LONG_MIN);
|
---|
1800 | CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e+20f), LONG_MIN);
|
---|
1801 | CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e-10f), 0);
|
---|
1802 | CHECK_LONG(RT_NOCRT(lrintf)( -2.1984e-40f), 0); /* subnormal */
|
---|
1803 | CHECK_LONG(RT_NOCRT(lrintf)(-INFINITY), LONG_MIN);
|
---|
1804 | CHECK_LONG(RT_NOCRT(lrintf)(+INFINITY), LONG_MIN);
|
---|
1805 | CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble(NULL, true)), LONG_MIN);
|
---|
1806 | CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble("s", false)), LONG_MIN);
|
---|
1807 | CHECK_LONG_SAME(lrintf,( -0.0f));
|
---|
1808 | CHECK_LONG_SAME(lrintf,( +0.0f));
|
---|
1809 | CHECK_LONG_SAME(lrintf,( +42.25f));
|
---|
1810 | CHECK_LONG_SAME(lrintf,( -42.25f));
|
---|
1811 | CHECK_LONG_SAME(lrintf,( +42.75f));
|
---|
1812 | CHECK_LONG_SAME(lrintf,( -42.75f));
|
---|
1813 | CHECK_LONG_SAME(lrintf,( +22.5f));
|
---|
1814 | CHECK_LONG_SAME(lrintf,( -22.5f));
|
---|
1815 | CHECK_LONG_SAME(lrintf,( +23.5f));
|
---|
1816 | CHECK_LONG_SAME(lrintf,( -23.5f));
|
---|
1817 | CHECK_LONG_SAME(lrintf,( +42.25e+6f));
|
---|
1818 | CHECK_LONG_SAME(lrintf,( -42.25e+6f));
|
---|
1819 | CHECK_LONG_SAME(lrintf,( -1234.499999e-10f));
|
---|
1820 | CHECK_LONG_SAME(lrintf,( -2.1984e-40f)); /* subnormal */
|
---|
1821 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
1822 | CHECK_LONG_SAME(lrintf,(+1234.60958634e+20f));
|
---|
1823 | CHECK_LONG_SAME(lrintf,(-1234.60958634e+20f));
|
---|
1824 | CHECK_LONG_SAME(lrintf,( -1234.499999e+20f));
|
---|
1825 | CHECK_LONG_SAME(lrintf,(-INFINITY));
|
---|
1826 | CHECK_LONG_SAME(lrintf,(+INFINITY));
|
---|
1827 | CHECK_LONG_SAME(lrintf,(RTStrNanFloat(NULL, true)));
|
---|
1828 | CHECK_LONG_SAME(lrintf,(RTStrNanFloat("s", false)));
|
---|
1829 | #endif
|
---|
1830 |
|
---|
1831 | /*
|
---|
1832 | * Round UP.
|
---|
1833 | */
|
---|
1834 | RT_NOCRT(fesetround)(FE_UPWARD);
|
---|
1835 |
|
---|
1836 | CHECK_LONG(RT_NOCRT(lrint)( +0.0), 0);
|
---|
1837 | CHECK_LONG(RT_NOCRT(lrint)( -0.0), 0);
|
---|
1838 | CHECK_LONG(RT_NOCRT(lrint)( -42.0), -42);
|
---|
1839 | CHECK_LONG(RT_NOCRT(lrint)( -42.5), -42);
|
---|
1840 | CHECK_LONG(RT_NOCRT(lrint)( +42.5), +43);
|
---|
1841 | CHECK_LONG(RT_NOCRT(lrint)( -43.5), -43);
|
---|
1842 | CHECK_LONG(RT_NOCRT(lrint)( +43.5), +44);
|
---|
1843 | CHECK_LONG(RT_NOCRT(lrint)( -42.25), -42);
|
---|
1844 | CHECK_LONG(RT_NOCRT(lrint)( +42.25), +43);
|
---|
1845 | CHECK_LONG(RT_NOCRT(lrint)( -42.75), -42);
|
---|
1846 | CHECK_LONG(RT_NOCRT(lrint)( +42.75), +43);
|
---|
1847 | CHECK_LONG(RT_NOCRT(lrint)(+1234.60958634e+20), LONG_MIN);
|
---|
1848 | CHECK_LONG(RT_NOCRT(lrint)(-1234.60958634e+20), LONG_MIN);
|
---|
1849 | CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e+20), LONG_MIN);
|
---|
1850 | CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e-10), 0);
|
---|
1851 | CHECK_LONG(RT_NOCRT(lrint)( -2.1984e-310), 0); /* subnormal */
|
---|
1852 | CHECK_LONG(RT_NOCRT(lrint)(-INFINITY), LONG_MIN);
|
---|
1853 | CHECK_LONG(RT_NOCRT(lrint)(+INFINITY), LONG_MIN);
|
---|
1854 | CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble(NULL, true)), LONG_MIN);
|
---|
1855 | CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble("s", false)), LONG_MIN);
|
---|
1856 | CHECK_LONG_SAME(lrint,( -0.0));
|
---|
1857 | CHECK_LONG_SAME(lrint,( +0.0));
|
---|
1858 | CHECK_LONG_SAME(lrint,( +42.25));
|
---|
1859 | CHECK_LONG_SAME(lrint,( -42.25));
|
---|
1860 | CHECK_LONG_SAME(lrint,( +42.75));
|
---|
1861 | CHECK_LONG_SAME(lrint,( -42.75));
|
---|
1862 | CHECK_LONG_SAME(lrint,( +22.5));
|
---|
1863 | CHECK_LONG_SAME(lrint,( -22.5));
|
---|
1864 | CHECK_LONG_SAME(lrint,( +23.5));
|
---|
1865 | CHECK_LONG_SAME(lrint,( -23.5));
|
---|
1866 | CHECK_LONG_SAME(lrint,( +42.25e+6));
|
---|
1867 | CHECK_LONG_SAME(lrint,( -42.25e+6));
|
---|
1868 | CHECK_LONG_SAME(lrint,( -1234.499999e-10));
|
---|
1869 | CHECK_LONG_SAME(lrint,( -2.1984e-310)); /* subnormal */
|
---|
1870 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
1871 | CHECK_LONG_SAME(lrint,(+1234.60958634e+20));
|
---|
1872 | CHECK_LONG_SAME(lrint,(-1234.60958634e+20));
|
---|
1873 | CHECK_LONG_SAME(lrint,( -1234.499999e+20));
|
---|
1874 | CHECK_LONG_SAME(lrint,(-INFINITY));
|
---|
1875 | CHECK_LONG_SAME(lrint,(+INFINITY));
|
---|
1876 | CHECK_LONG_SAME(lrint,(RTStrNanDouble(NULL, true)));
|
---|
1877 | CHECK_LONG_SAME(lrint,(RTStrNanDouble("s", false)));
|
---|
1878 | #endif
|
---|
1879 |
|
---|
1880 | CHECK_LONG(RT_NOCRT(lrintf)( +0.0f), 0);
|
---|
1881 | CHECK_LONG(RT_NOCRT(lrintf)( -0.0f), 0);
|
---|
1882 | CHECK_LONG(RT_NOCRT(lrintf)( -42.0f), -42);
|
---|
1883 | CHECK_LONG(RT_NOCRT(lrintf)( -42.5f), -42);
|
---|
1884 | CHECK_LONG(RT_NOCRT(lrintf)( +42.5f), +43);
|
---|
1885 | CHECK_LONG(RT_NOCRT(lrintf)( -43.5f), -43);
|
---|
1886 | CHECK_LONG(RT_NOCRT(lrintf)( +43.5f), +44);
|
---|
1887 | CHECK_LONG(RT_NOCRT(lrintf)( -42.25f), -42);
|
---|
1888 | CHECK_LONG(RT_NOCRT(lrintf)( +42.25f), +43);
|
---|
1889 | CHECK_LONG(RT_NOCRT(lrintf)( -42.75f), -42);
|
---|
1890 | CHECK_LONG(RT_NOCRT(lrintf)( +42.75f), +43);
|
---|
1891 | CHECK_LONG(RT_NOCRT(lrintf)(+1234.60958634e+20f), LONG_MIN);
|
---|
1892 | CHECK_LONG(RT_NOCRT(lrintf)(-1234.60958634e+20f), LONG_MIN);
|
---|
1893 | CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e+20f), LONG_MIN);
|
---|
1894 | CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e-10f), 0);
|
---|
1895 | CHECK_LONG(RT_NOCRT(lrintf)( -2.1984e-40f), 0); /* subnormal */
|
---|
1896 | CHECK_LONG(RT_NOCRT(lrintf)(-INFINITY), LONG_MIN);
|
---|
1897 | CHECK_LONG(RT_NOCRT(lrintf)(+INFINITY), LONG_MIN);
|
---|
1898 | CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble(NULL, true)), LONG_MIN);
|
---|
1899 | CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble("s", false)), LONG_MIN);
|
---|
1900 | CHECK_LONG_SAME(lrintf,( -0.0f));
|
---|
1901 | CHECK_LONG_SAME(lrintf,( +0.0f));
|
---|
1902 | CHECK_LONG_SAME(lrintf,( +42.25f));
|
---|
1903 | CHECK_LONG_SAME(lrintf,( -42.25f));
|
---|
1904 | CHECK_LONG_SAME(lrintf,( +42.75f));
|
---|
1905 | CHECK_LONG_SAME(lrintf,( -42.75f));
|
---|
1906 | CHECK_LONG_SAME(lrintf,( +22.5f));
|
---|
1907 | CHECK_LONG_SAME(lrintf,( -22.5f));
|
---|
1908 | CHECK_LONG_SAME(lrintf,( +23.5f));
|
---|
1909 | CHECK_LONG_SAME(lrintf,( -23.5f));
|
---|
1910 | CHECK_LONG_SAME(lrintf,( +42.25e+6f));
|
---|
1911 | CHECK_LONG_SAME(lrintf,( -42.25e+6f));
|
---|
1912 | CHECK_LONG_SAME(lrintf,( -1234.499999e-10f));
|
---|
1913 | CHECK_LONG_SAME(lrintf,( -2.1984e-40f)); /* subnormal */
|
---|
1914 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
1915 | CHECK_LONG_SAME(lrintf,(+1234.60958634e+20f));
|
---|
1916 | CHECK_LONG_SAME(lrintf,(-1234.60958634e+20f));
|
---|
1917 | CHECK_LONG_SAME(lrintf,( -1234.499999e+20f));
|
---|
1918 | CHECK_LONG_SAME(lrintf,(-INFINITY));
|
---|
1919 | CHECK_LONG_SAME(lrintf,(+INFINITY));
|
---|
1920 | CHECK_LONG_SAME(lrintf,(RTStrNanFloat(NULL, true)));
|
---|
1921 | CHECK_LONG_SAME(lrintf,(RTStrNanFloat("s", false)));
|
---|
1922 | #endif
|
---|
1923 |
|
---|
1924 | /*
|
---|
1925 | * Round DOWN.
|
---|
1926 | */
|
---|
1927 | RT_NOCRT(fesetround)(FE_DOWNWARD);
|
---|
1928 |
|
---|
1929 | CHECK_LONG(RT_NOCRT(lrint)( +0.0), 0);
|
---|
1930 | CHECK_LONG(RT_NOCRT(lrint)( -0.0), 0);
|
---|
1931 | CHECK_LONG(RT_NOCRT(lrint)( -42.0), -42);
|
---|
1932 | CHECK_LONG(RT_NOCRT(lrint)( -42.5), -43);
|
---|
1933 | CHECK_LONG(RT_NOCRT(lrint)( +42.5), +42);
|
---|
1934 | CHECK_LONG(RT_NOCRT(lrint)( -43.5), -44);
|
---|
1935 | CHECK_LONG(RT_NOCRT(lrint)( +43.5), +43);
|
---|
1936 | CHECK_LONG(RT_NOCRT(lrint)( -42.25), -43);
|
---|
1937 | CHECK_LONG(RT_NOCRT(lrint)( +42.25), +42);
|
---|
1938 | CHECK_LONG(RT_NOCRT(lrint)( -42.75), -43);
|
---|
1939 | CHECK_LONG(RT_NOCRT(lrint)( +42.75), +42);
|
---|
1940 | CHECK_LONG(RT_NOCRT(lrint)(+1234.60958634e+20), LONG_MIN);
|
---|
1941 | CHECK_LONG(RT_NOCRT(lrint)(-1234.60958634e+20), LONG_MIN);
|
---|
1942 | CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e+20), LONG_MIN);
|
---|
1943 | CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e-10), -1);
|
---|
1944 | CHECK_LONG(RT_NOCRT(lrint)( -2.1984e-310), -1); /* subnormal */
|
---|
1945 | CHECK_LONG(RT_NOCRT(lrint)(-INFINITY), LONG_MIN);
|
---|
1946 | CHECK_LONG(RT_NOCRT(lrint)(+INFINITY), LONG_MIN);
|
---|
1947 | CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble(NULL, true)), LONG_MIN);
|
---|
1948 | CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble("s", false)), LONG_MIN);
|
---|
1949 | CHECK_LONG_SAME(lrint,( -0.0));
|
---|
1950 | CHECK_LONG_SAME(lrint,( +0.0));
|
---|
1951 | CHECK_LONG_SAME(lrint,( +42.25));
|
---|
1952 | CHECK_LONG_SAME(lrint,( -42.25));
|
---|
1953 | CHECK_LONG_SAME(lrint,( +42.75));
|
---|
1954 | CHECK_LONG_SAME(lrint,( -42.75));
|
---|
1955 | CHECK_LONG_SAME(lrint,( +22.5));
|
---|
1956 | CHECK_LONG_SAME(lrint,( -22.5));
|
---|
1957 | CHECK_LONG_SAME(lrint,( +23.5));
|
---|
1958 | CHECK_LONG_SAME(lrint,( -23.5));
|
---|
1959 | CHECK_LONG_SAME(lrint,( +42.25e+6));
|
---|
1960 | CHECK_LONG_SAME(lrint,( -42.25e+6));
|
---|
1961 | CHECK_LONG_SAME(lrint,( -1234.499999e-10));
|
---|
1962 | CHECK_LONG_SAME(lrint,( -2.1984e-310)); /* subnormal */
|
---|
1963 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
1964 | CHECK_LONG_SAME(lrint,(+1234.60958634e+20));
|
---|
1965 | CHECK_LONG_SAME(lrint,(-1234.60958634e+20));
|
---|
1966 | CHECK_LONG_SAME(lrint,( -1234.499999e+20));
|
---|
1967 | CHECK_LONG_SAME(lrint,(-INFINITY));
|
---|
1968 | CHECK_LONG_SAME(lrint,(+INFINITY));
|
---|
1969 | CHECK_LONG_SAME(lrint,(RTStrNanDouble(NULL, true)));
|
---|
1970 | CHECK_LONG_SAME(lrint,(RTStrNanDouble("s", false)));
|
---|
1971 | #endif
|
---|
1972 |
|
---|
1973 | CHECK_LONG(RT_NOCRT(lrintf)( +0.0f), 0);
|
---|
1974 | CHECK_LONG(RT_NOCRT(lrintf)( -0.0f), 0);
|
---|
1975 | CHECK_LONG(RT_NOCRT(lrintf)( -42.0f), -42);
|
---|
1976 | CHECK_LONG(RT_NOCRT(lrintf)( -42.5f), -43);
|
---|
1977 | CHECK_LONG(RT_NOCRT(lrintf)( +42.5f), +42);
|
---|
1978 | CHECK_LONG(RT_NOCRT(lrintf)( -43.5f), -44);
|
---|
1979 | CHECK_LONG(RT_NOCRT(lrintf)( +43.5f), +43);
|
---|
1980 | CHECK_LONG(RT_NOCRT(lrintf)( -42.25f), -43);
|
---|
1981 | CHECK_LONG(RT_NOCRT(lrintf)( +42.25f), +42);
|
---|
1982 | CHECK_LONG(RT_NOCRT(lrintf)( -42.75f), -43);
|
---|
1983 | CHECK_LONG(RT_NOCRT(lrintf)( +42.75f), +42);
|
---|
1984 | CHECK_LONG(RT_NOCRT(lrintf)(+1234.60958634e+20f), LONG_MIN);
|
---|
1985 | CHECK_LONG(RT_NOCRT(lrintf)(-1234.60958634e+20f), LONG_MIN);
|
---|
1986 | CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e+20f), LONG_MIN);
|
---|
1987 | CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e-10f), -1);
|
---|
1988 | CHECK_LONG(RT_NOCRT(lrintf)( -2.1984e-40f), -1); /* subnormal */
|
---|
1989 | CHECK_LONG(RT_NOCRT(lrintf)(-INFINITY), LONG_MIN);
|
---|
1990 | CHECK_LONG(RT_NOCRT(lrintf)(+INFINITY), LONG_MIN);
|
---|
1991 | CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble(NULL, true)), LONG_MIN);
|
---|
1992 | CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble("s", false)), LONG_MIN);
|
---|
1993 | CHECK_LONG_SAME(lrintf,( -0.0f));
|
---|
1994 | CHECK_LONG_SAME(lrintf,( +0.0f));
|
---|
1995 | CHECK_LONG_SAME(lrintf,( +42.25f));
|
---|
1996 | CHECK_LONG_SAME(lrintf,( -42.25f));
|
---|
1997 | CHECK_LONG_SAME(lrintf,( +42.75f));
|
---|
1998 | CHECK_LONG_SAME(lrintf,( -42.75f));
|
---|
1999 | CHECK_LONG_SAME(lrintf,( +22.5f));
|
---|
2000 | CHECK_LONG_SAME(lrintf,( -22.5f));
|
---|
2001 | CHECK_LONG_SAME(lrintf,( +23.5f));
|
---|
2002 | CHECK_LONG_SAME(lrintf,( -23.5f));
|
---|
2003 | CHECK_LONG_SAME(lrintf,( +42.25e+6f));
|
---|
2004 | CHECK_LONG_SAME(lrintf,( -42.25e+6f));
|
---|
2005 | CHECK_LONG_SAME(lrintf,( -1234.499999e-10f));
|
---|
2006 | CHECK_LONG_SAME(lrintf,( -2.1984e-40f)); /* subnormal */
|
---|
2007 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
2008 | CHECK_LONG_SAME(lrintf,(+1234.60958634e+20f));
|
---|
2009 | CHECK_LONG_SAME(lrintf,(-1234.60958634e+20f));
|
---|
2010 | CHECK_LONG_SAME(lrintf,( -1234.499999e+20f));
|
---|
2011 | CHECK_LONG_SAME(lrintf,(-INFINITY));
|
---|
2012 | CHECK_LONG_SAME(lrintf,(+INFINITY));
|
---|
2013 | CHECK_LONG_SAME(lrintf,(RTStrNanFloat(NULL, true)));
|
---|
2014 | CHECK_LONG_SAME(lrintf,(RTStrNanFloat("s", false)));
|
---|
2015 | #endif
|
---|
2016 |
|
---|
2017 | /*
|
---|
2018 | * Round towards ZERO.
|
---|
2019 | */
|
---|
2020 | RT_NOCRT(fesetround)(FE_TOWARDZERO);
|
---|
2021 |
|
---|
2022 | CHECK_LONG(RT_NOCRT(lrint)( +0.0), 0);
|
---|
2023 | CHECK_LONG(RT_NOCRT(lrint)( -0.0), 0);
|
---|
2024 | CHECK_LONG(RT_NOCRT(lrint)( -42.0), -42);
|
---|
2025 | CHECK_LONG(RT_NOCRT(lrint)( -42.5), -42);
|
---|
2026 | CHECK_LONG(RT_NOCRT(lrint)( +42.5), +42);
|
---|
2027 | CHECK_LONG(RT_NOCRT(lrint)( -43.5), -43);
|
---|
2028 | CHECK_LONG(RT_NOCRT(lrint)( +43.5), +43);
|
---|
2029 | CHECK_LONG(RT_NOCRT(lrint)( -42.25), -42);
|
---|
2030 | CHECK_LONG(RT_NOCRT(lrint)( +42.25), +42);
|
---|
2031 | CHECK_LONG(RT_NOCRT(lrint)( -42.75), -42);
|
---|
2032 | CHECK_LONG(RT_NOCRT(lrint)( +42.75), +42);
|
---|
2033 | CHECK_LONG(RT_NOCRT(lrint)(+1234.60958634e+20), LONG_MIN);
|
---|
2034 | CHECK_LONG(RT_NOCRT(lrint)(-1234.60958634e+20), LONG_MIN);
|
---|
2035 | CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e+20), LONG_MIN);
|
---|
2036 | CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e-10), 0);
|
---|
2037 | CHECK_LONG(RT_NOCRT(lrint)( -2.1984e-310), 0); /* subnormal */
|
---|
2038 | CHECK_LONG(RT_NOCRT(lrint)(-INFINITY), LONG_MIN);
|
---|
2039 | CHECK_LONG(RT_NOCRT(lrint)(+INFINITY), LONG_MIN);
|
---|
2040 | CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble(NULL, true)), LONG_MIN);
|
---|
2041 | CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble("s", false)), LONG_MIN);
|
---|
2042 | CHECK_LONG_SAME(lrint,( -0.0));
|
---|
2043 | CHECK_LONG_SAME(lrint,( +0.0));
|
---|
2044 | CHECK_LONG_SAME(lrint,( +42.25));
|
---|
2045 | CHECK_LONG_SAME(lrint,( -42.25));
|
---|
2046 | CHECK_LONG_SAME(lrint,( +42.75));
|
---|
2047 | CHECK_LONG_SAME(lrint,( -42.75));
|
---|
2048 | CHECK_LONG_SAME(lrint,( +22.5));
|
---|
2049 | CHECK_LONG_SAME(lrint,( -22.5));
|
---|
2050 | CHECK_LONG_SAME(lrint,( +23.5));
|
---|
2051 | CHECK_LONG_SAME(lrint,( -23.5));
|
---|
2052 | CHECK_LONG_SAME(lrint,( +42.25e+6));
|
---|
2053 | CHECK_LONG_SAME(lrint,( -42.25e+6));
|
---|
2054 | CHECK_LONG_SAME(lrint,( -1234.499999e-10));
|
---|
2055 | CHECK_LONG_SAME(lrint,( -2.1984e-310)); /* subnormal */
|
---|
2056 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
2057 | CHECK_LONG_SAME(lrint,(+1234.60958634e+20));
|
---|
2058 | CHECK_LONG_SAME(lrint,(-1234.60958634e+20));
|
---|
2059 | CHECK_LONG_SAME(lrint,( -1234.499999e+20));
|
---|
2060 | CHECK_LONG_SAME(lrint,(-INFINITY));
|
---|
2061 | CHECK_LONG_SAME(lrint,(+INFINITY));
|
---|
2062 | CHECK_LONG_SAME(lrint,(RTStrNanDouble(NULL, true)));
|
---|
2063 | CHECK_LONG_SAME(lrint,(RTStrNanDouble("s", false)));
|
---|
2064 | #endif
|
---|
2065 |
|
---|
2066 | CHECK_LONG(RT_NOCRT(lrintf)( +0.0f), 0);
|
---|
2067 | CHECK_LONG(RT_NOCRT(lrintf)( -0.0f), 0);
|
---|
2068 | CHECK_LONG(RT_NOCRT(lrintf)( -42.0f), -42);
|
---|
2069 | CHECK_LONG(RT_NOCRT(lrintf)( -42.5f), -42);
|
---|
2070 | CHECK_LONG(RT_NOCRT(lrintf)( +42.5f), +42);
|
---|
2071 | CHECK_LONG(RT_NOCRT(lrintf)( -43.5f), -43);
|
---|
2072 | CHECK_LONG(RT_NOCRT(lrintf)( +43.5f), +43);
|
---|
2073 | CHECK_LONG(RT_NOCRT(lrintf)( -42.25f), -42);
|
---|
2074 | CHECK_LONG(RT_NOCRT(lrintf)( +42.25f), +42);
|
---|
2075 | CHECK_LONG(RT_NOCRT(lrintf)( -42.75f), -42);
|
---|
2076 | CHECK_LONG(RT_NOCRT(lrintf)( +42.75f), +42);
|
---|
2077 | CHECK_LONG(RT_NOCRT(lrintf)(+1234.60958634e+20f), LONG_MIN);
|
---|
2078 | CHECK_LONG(RT_NOCRT(lrintf)(-1234.60958634e+20f), LONG_MIN);
|
---|
2079 | CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e+20f), LONG_MIN);
|
---|
2080 | CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e-10f), 0);
|
---|
2081 | CHECK_LONG(RT_NOCRT(lrintf)( -2.1984e-40f), 0); /* subnormal */
|
---|
2082 | CHECK_LONG(RT_NOCRT(lrintf)(-INFINITY), LONG_MIN);
|
---|
2083 | CHECK_LONG(RT_NOCRT(lrintf)(+INFINITY), LONG_MIN);
|
---|
2084 | CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble(NULL, true)), LONG_MIN);
|
---|
2085 | CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble("s", false)), LONG_MIN);
|
---|
2086 | CHECK_LONG_SAME(lrintf,( -0.0f));
|
---|
2087 | CHECK_LONG_SAME(lrintf,( +0.0f));
|
---|
2088 | CHECK_LONG_SAME(lrintf,( +42.25f));
|
---|
2089 | CHECK_LONG_SAME(lrintf,( -42.25f));
|
---|
2090 | CHECK_LONG_SAME(lrintf,( +42.75f));
|
---|
2091 | CHECK_LONG_SAME(lrintf,( -42.75f));
|
---|
2092 | CHECK_LONG_SAME(lrintf,( +22.5f));
|
---|
2093 | CHECK_LONG_SAME(lrintf,( -22.5f));
|
---|
2094 | CHECK_LONG_SAME(lrintf,( +23.5f));
|
---|
2095 | CHECK_LONG_SAME(lrintf,( -23.5f));
|
---|
2096 | CHECK_LONG_SAME(lrintf,( +42.25e+6f));
|
---|
2097 | CHECK_LONG_SAME(lrintf,( -42.25e+6f));
|
---|
2098 | CHECK_LONG_SAME(lrintf,( -1234.499999e-10f));
|
---|
2099 | CHECK_LONG_SAME(lrintf,( -2.1984e-40f)); /* subnormal */
|
---|
2100 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
2101 | CHECK_LONG_SAME(lrintf,(+1234.60958634e+20f));
|
---|
2102 | CHECK_LONG_SAME(lrintf,(-1234.60958634e+20f));
|
---|
2103 | CHECK_LONG_SAME(lrintf,( -1234.499999e+20f));
|
---|
2104 | CHECK_LONG_SAME(lrintf,(-INFINITY));
|
---|
2105 | CHECK_LONG_SAME(lrintf,(+INFINITY));
|
---|
2106 | CHECK_LONG_SAME(lrintf,(RTStrNanFloat(NULL, true)));
|
---|
2107 | CHECK_LONG_SAME(lrintf,(RTStrNanFloat("s", false)));
|
---|
2108 | #endif
|
---|
2109 |
|
---|
2110 | RT_NOCRT(fesetround)(iSavedMode);
|
---|
2111 | }
|
---|
2112 |
|
---|
2113 |
|
---|
2114 | void testLLRInt()
|
---|
2115 | {
|
---|
2116 | RTTestSub(g_hTest, "llrint[f]");
|
---|
2117 |
|
---|
2118 | /*
|
---|
2119 | * Round nearest.
|
---|
2120 | */
|
---|
2121 | int const iSavedMode = RT_NOCRT(fegetround)();
|
---|
2122 | if (iSavedMode != FE_TONEAREST)
|
---|
2123 | RTTestFailed(g_hTest, "expected FE_TONEAREST as default rounding mode, not %#x (%d)", iSavedMode, iSavedMode);
|
---|
2124 | RT_NOCRT(fesetround)(FE_TONEAREST);
|
---|
2125 |
|
---|
2126 | CHECK_LLONG(RT_NOCRT(llrint)( +0.0), 0);
|
---|
2127 | CHECK_LLONG(RT_NOCRT(llrint)( -0.0), 0);
|
---|
2128 | CHECK_LLONG(RT_NOCRT(llrint)( -42.0), -42);
|
---|
2129 | CHECK_LLONG(RT_NOCRT(llrint)( -42.5), -42);
|
---|
2130 | CHECK_LLONG(RT_NOCRT(llrint)( +42.5), +42);
|
---|
2131 | CHECK_LLONG(RT_NOCRT(llrint)( -43.5), -44);
|
---|
2132 | CHECK_LLONG(RT_NOCRT(llrint)( +43.5), +44);
|
---|
2133 | CHECK_LLONG(RT_NOCRT(llrint)( -42.25), -42);
|
---|
2134 | CHECK_LLONG(RT_NOCRT(llrint)( +42.25), +42);
|
---|
2135 | CHECK_LLONG(RT_NOCRT(llrint)( -42.75), -43);
|
---|
2136 | CHECK_LLONG(RT_NOCRT(llrint)( +42.75), +43);
|
---|
2137 | CHECK_LLONG(RT_NOCRT(llrint)(+1234.60958634e+20), LLONG_MIN);
|
---|
2138 | CHECK_LLONG(RT_NOCRT(llrint)(-1234.60958634e+20), LLONG_MIN);
|
---|
2139 | CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e+20), LLONG_MIN);
|
---|
2140 | CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e-10), 0);
|
---|
2141 | CHECK_LLONG(RT_NOCRT(llrint)( -2.1984e-310), 0); /* subnormal */
|
---|
2142 | CHECK_LLONG(RT_NOCRT(llrint)(-INFINITY), LLONG_MIN);
|
---|
2143 | CHECK_LLONG(RT_NOCRT(llrint)(+INFINITY), LLONG_MIN);
|
---|
2144 | CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble(NULL, true)),LLONG_MIN);
|
---|
2145 | CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble("s", false)),LLONG_MIN);
|
---|
2146 | CHECK_LLONG_SAME(llrint,( -0.0));
|
---|
2147 | CHECK_LLONG_SAME(llrint,( +0.0));
|
---|
2148 | CHECK_LLONG_SAME(llrint,( +42.25));
|
---|
2149 | CHECK_LLONG_SAME(llrint,( -42.25));
|
---|
2150 | CHECK_LLONG_SAME(llrint,( +42.75));
|
---|
2151 | CHECK_LLONG_SAME(llrint,( -42.75));
|
---|
2152 | CHECK_LLONG_SAME(llrint,( +22.5));
|
---|
2153 | CHECK_LLONG_SAME(llrint,( -22.5));
|
---|
2154 | CHECK_LLONG_SAME(llrint,( +23.5));
|
---|
2155 | CHECK_LLONG_SAME(llrint,( -23.5));
|
---|
2156 | CHECK_LLONG_SAME(llrint,( +42.25e+6));
|
---|
2157 | CHECK_LLONG_SAME(llrint,( -42.25e+6));
|
---|
2158 | CHECK_LLONG_SAME(llrint,( -1234.499999e-10));
|
---|
2159 | CHECK_LLONG_SAME(llrint,( -2.1984e-310)); /* subnormal */
|
---|
2160 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
2161 | CHECK_LLONG_SAME(llrint,(+1234.60958634e+20));
|
---|
2162 | CHECK_LLONG_SAME(llrint,(-1234.60958634e+20));
|
---|
2163 | CHECK_LLONG_SAME(llrint,( -1234.499999e+20));
|
---|
2164 | CHECK_LLONG_SAME(llrint,(-INFINITY));
|
---|
2165 | CHECK_LLONG_SAME(llrint,(+INFINITY));
|
---|
2166 | CHECK_LLONG_SAME(llrint,(RTStrNanDouble(NULL, true)));
|
---|
2167 | CHECK_LLONG_SAME(llrint,(RTStrNanDouble("s", false)));
|
---|
2168 | #endif
|
---|
2169 |
|
---|
2170 | CHECK_LLONG(RT_NOCRT(llrintf)( +0.0f), 0);
|
---|
2171 | CHECK_LLONG(RT_NOCRT(llrintf)( -0.0f), 0);
|
---|
2172 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.0f), -42);
|
---|
2173 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.5f), -42);
|
---|
2174 | CHECK_LLONG(RT_NOCRT(llrintf)( +42.5f), +42);
|
---|
2175 | CHECK_LLONG(RT_NOCRT(llrintf)( -43.5f), -44);
|
---|
2176 | CHECK_LLONG(RT_NOCRT(llrintf)( +43.5f), +44);
|
---|
2177 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.25f), -42);
|
---|
2178 | CHECK_LLONG(RT_NOCRT(llrintf)( +42.25f), +42);
|
---|
2179 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.75f), -43);
|
---|
2180 | CHECK_LLONG(RT_NOCRT(llrintf)( +42.75f), +43);
|
---|
2181 | CHECK_LLONG(RT_NOCRT(llrintf)(+1234.60958634e+20f), LLONG_MIN);
|
---|
2182 | CHECK_LLONG(RT_NOCRT(llrintf)(-1234.60958634e+20f), LLONG_MIN);
|
---|
2183 | CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e+20f), LLONG_MIN);
|
---|
2184 | CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e-10f), 0);
|
---|
2185 | CHECK_LLONG(RT_NOCRT(llrintf)( -2.1984e-40f), 0); /* subnormal */
|
---|
2186 | CHECK_LLONG(RT_NOCRT(llrintf)(-INFINITY), LLONG_MIN);
|
---|
2187 | CHECK_LLONG(RT_NOCRT(llrintf)(+INFINITY), LLONG_MIN);
|
---|
2188 | CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble(NULL, true)), LLONG_MIN);
|
---|
2189 | CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble("s", false)), LLONG_MIN);
|
---|
2190 | CHECK_LLONG_SAME(llrintf,( -0.0f));
|
---|
2191 | CHECK_LLONG_SAME(llrintf,( +0.0f));
|
---|
2192 | CHECK_LLONG_SAME(llrintf,( +42.25f));
|
---|
2193 | CHECK_LLONG_SAME(llrintf,( -42.25f));
|
---|
2194 | CHECK_LLONG_SAME(llrintf,( +42.75f));
|
---|
2195 | CHECK_LLONG_SAME(llrintf,( -42.75f));
|
---|
2196 | CHECK_LLONG_SAME(llrintf,( +22.5f));
|
---|
2197 | CHECK_LLONG_SAME(llrintf,( -22.5f));
|
---|
2198 | CHECK_LLONG_SAME(llrintf,( +23.5f));
|
---|
2199 | CHECK_LLONG_SAME(llrintf,( -23.5f));
|
---|
2200 | CHECK_LLONG_SAME(llrintf,( +42.25e+6f));
|
---|
2201 | CHECK_LLONG_SAME(llrintf,( -42.25e+6f));
|
---|
2202 | CHECK_LLONG_SAME(llrintf,( -1234.499999e-10f));
|
---|
2203 | CHECK_LLONG_SAME(llrintf,( -2.1984e-40f)); /* subnormal */
|
---|
2204 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
2205 | CHECK_LLONG_SAME(llrintf,(+1234.60958634e+20f));
|
---|
2206 | CHECK_LLONG_SAME(llrintf,(-1234.60958634e+20f));
|
---|
2207 | CHECK_LLONG_SAME(llrintf,( -1234.499999e+20f));
|
---|
2208 | CHECK_LLONG_SAME(llrintf,(-INFINITY));
|
---|
2209 | CHECK_LLONG_SAME(llrintf,(+INFINITY));
|
---|
2210 | CHECK_LLONG_SAME(llrintf,(RTStrNanFloat(NULL, true)));
|
---|
2211 | CHECK_LLONG_SAME(llrintf,(RTStrNanFloat("s", false)));
|
---|
2212 | #endif
|
---|
2213 |
|
---|
2214 | /*
|
---|
2215 | * Round UP.
|
---|
2216 | */
|
---|
2217 | RT_NOCRT(fesetround)(FE_UPWARD);
|
---|
2218 |
|
---|
2219 | CHECK_LLONG(RT_NOCRT(llrint)( +0.0), 0);
|
---|
2220 | CHECK_LLONG(RT_NOCRT(llrint)( -0.0), 0);
|
---|
2221 | CHECK_LLONG(RT_NOCRT(llrint)( -42.0), -42);
|
---|
2222 | CHECK_LLONG(RT_NOCRT(llrint)( -42.5), -42);
|
---|
2223 | CHECK_LLONG(RT_NOCRT(llrint)( +42.5), +43);
|
---|
2224 | CHECK_LLONG(RT_NOCRT(llrint)( -43.5), -43);
|
---|
2225 | CHECK_LLONG(RT_NOCRT(llrint)( +43.5), +44);
|
---|
2226 | CHECK_LLONG(RT_NOCRT(llrint)( -42.25), -42);
|
---|
2227 | CHECK_LLONG(RT_NOCRT(llrint)( +42.25), +43);
|
---|
2228 | CHECK_LLONG(RT_NOCRT(llrint)( -42.75), -42);
|
---|
2229 | CHECK_LLONG(RT_NOCRT(llrint)( +42.75), +43);
|
---|
2230 | CHECK_LLONG(RT_NOCRT(llrint)(+1234.60958634e+20), LLONG_MIN);
|
---|
2231 | CHECK_LLONG(RT_NOCRT(llrint)(-1234.60958634e+20), LLONG_MIN);
|
---|
2232 | CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e+20), LLONG_MIN);
|
---|
2233 | CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e-10), 0);
|
---|
2234 | CHECK_LLONG(RT_NOCRT(llrint)( -2.1984e-310), 0); /* subnormal */
|
---|
2235 | CHECK_LLONG(RT_NOCRT(llrint)(-INFINITY), LLONG_MIN);
|
---|
2236 | CHECK_LLONG(RT_NOCRT(llrint)(+INFINITY), LLONG_MIN);
|
---|
2237 | CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble(NULL, true)),LLONG_MIN);
|
---|
2238 | CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble("s", false)),LLONG_MIN);
|
---|
2239 | CHECK_LLONG_SAME(llrint,( -0.0));
|
---|
2240 | CHECK_LLONG_SAME(llrint,( +0.0));
|
---|
2241 | CHECK_LLONG_SAME(llrint,( +42.25));
|
---|
2242 | CHECK_LLONG_SAME(llrint,( -42.25));
|
---|
2243 | CHECK_LLONG_SAME(llrint,( +42.75));
|
---|
2244 | CHECK_LLONG_SAME(llrint,( -42.75));
|
---|
2245 | CHECK_LLONG_SAME(llrint,( +22.5));
|
---|
2246 | CHECK_LLONG_SAME(llrint,( -22.5));
|
---|
2247 | CHECK_LLONG_SAME(llrint,( +23.5));
|
---|
2248 | CHECK_LLONG_SAME(llrint,( -23.5));
|
---|
2249 | CHECK_LLONG_SAME(llrint,( +42.25e+6));
|
---|
2250 | CHECK_LLONG_SAME(llrint,( -42.25e+6));
|
---|
2251 | CHECK_LLONG_SAME(llrint,( -1234.499999e-10));
|
---|
2252 | CHECK_LLONG_SAME(llrint,( -2.1984e-310)); /* subnormal */
|
---|
2253 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
2254 | CHECK_LLONG_SAME(llrint,(+1234.60958634e+20));
|
---|
2255 | CHECK_LLONG_SAME(llrint,(-1234.60958634e+20));
|
---|
2256 | CHECK_LLONG_SAME(llrint,( -1234.499999e+20));
|
---|
2257 | CHECK_LLONG_SAME(llrint,(-INFINITY));
|
---|
2258 | CHECK_LLONG_SAME(llrint,(+INFINITY));
|
---|
2259 | CHECK_LLONG_SAME(llrint,(RTStrNanDouble(NULL, true)));
|
---|
2260 | CHECK_LLONG_SAME(llrint,(RTStrNanDouble("s", false)));
|
---|
2261 | #endif
|
---|
2262 |
|
---|
2263 | CHECK_LLONG(RT_NOCRT(llrintf)( +0.0f), 0);
|
---|
2264 | CHECK_LLONG(RT_NOCRT(llrintf)( -0.0f), 0);
|
---|
2265 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.0f), -42);
|
---|
2266 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.5f), -42);
|
---|
2267 | CHECK_LLONG(RT_NOCRT(llrintf)( +42.5f), +43);
|
---|
2268 | CHECK_LLONG(RT_NOCRT(llrintf)( -43.5f), -43);
|
---|
2269 | CHECK_LLONG(RT_NOCRT(llrintf)( +43.5f), +44);
|
---|
2270 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.25f), -42);
|
---|
2271 | CHECK_LLONG(RT_NOCRT(llrintf)( +42.25f), +43);
|
---|
2272 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.75f), -42);
|
---|
2273 | CHECK_LLONG(RT_NOCRT(llrintf)( +42.75f), +43);
|
---|
2274 | CHECK_LLONG(RT_NOCRT(llrintf)(+1234.60958634e+20f), LLONG_MIN);
|
---|
2275 | CHECK_LLONG(RT_NOCRT(llrintf)(-1234.60958634e+20f), LLONG_MIN);
|
---|
2276 | CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e+20f), LLONG_MIN);
|
---|
2277 | CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e-10f), 0);
|
---|
2278 | CHECK_LLONG(RT_NOCRT(llrintf)( -2.1984e-40f), 0); /* subnormal */
|
---|
2279 | CHECK_LLONG(RT_NOCRT(llrintf)(-INFINITY), LLONG_MIN);
|
---|
2280 | CHECK_LLONG(RT_NOCRT(llrintf)(+INFINITY), LLONG_MIN);
|
---|
2281 | CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble(NULL, true)), LLONG_MIN);
|
---|
2282 | CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble("s", false)), LLONG_MIN);
|
---|
2283 | CHECK_LLONG_SAME(llrintf,( -0.0f));
|
---|
2284 | CHECK_LLONG_SAME(llrintf,( +0.0f));
|
---|
2285 | CHECK_LLONG_SAME(llrintf,( +42.25f));
|
---|
2286 | CHECK_LLONG_SAME(llrintf,( -42.25f));
|
---|
2287 | CHECK_LLONG_SAME(llrintf,( +42.75f));
|
---|
2288 | CHECK_LLONG_SAME(llrintf,( -42.75f));
|
---|
2289 | CHECK_LLONG_SAME(llrintf,( +22.5f));
|
---|
2290 | CHECK_LLONG_SAME(llrintf,( -22.5f));
|
---|
2291 | CHECK_LLONG_SAME(llrintf,( +23.5f));
|
---|
2292 | CHECK_LLONG_SAME(llrintf,( -23.5f));
|
---|
2293 | CHECK_LLONG_SAME(llrintf,( +42.25e+6f));
|
---|
2294 | CHECK_LLONG_SAME(llrintf,( -42.25e+6f));
|
---|
2295 | CHECK_LLONG_SAME(llrintf,( -1234.499999e-10f));
|
---|
2296 | CHECK_LLONG_SAME(llrintf,( -2.1984e-40f)); /* subnormal */
|
---|
2297 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
2298 | CHECK_LLONG_SAME(llrintf,(+1234.60958634e+20f));
|
---|
2299 | CHECK_LLONG_SAME(llrintf,(-1234.60958634e+20f));
|
---|
2300 | CHECK_LLONG_SAME(llrintf,( -1234.499999e+20f));
|
---|
2301 | CHECK_LLONG_SAME(llrintf,(-INFINITY));
|
---|
2302 | CHECK_LLONG_SAME(llrintf,(+INFINITY));
|
---|
2303 | CHECK_LLONG_SAME(llrintf,(RTStrNanFloat(NULL, true)));
|
---|
2304 | CHECK_LLONG_SAME(llrintf,(RTStrNanFloat("s", false)));
|
---|
2305 | #endif
|
---|
2306 |
|
---|
2307 | /*
|
---|
2308 | * Round DOWN.
|
---|
2309 | */
|
---|
2310 | RT_NOCRT(fesetround)(FE_DOWNWARD);
|
---|
2311 |
|
---|
2312 | CHECK_LLONG(RT_NOCRT(llrint)( +0.0), 0);
|
---|
2313 | CHECK_LLONG(RT_NOCRT(llrint)( -0.0), 0);
|
---|
2314 | CHECK_LLONG(RT_NOCRT(llrint)( -42.0), -42);
|
---|
2315 | CHECK_LLONG(RT_NOCRT(llrint)( -42.5), -43);
|
---|
2316 | CHECK_LLONG(RT_NOCRT(llrint)( +42.5), +42);
|
---|
2317 | CHECK_LLONG(RT_NOCRT(llrint)( -43.5), -44);
|
---|
2318 | CHECK_LLONG(RT_NOCRT(llrint)( +43.5), +43);
|
---|
2319 | CHECK_LLONG(RT_NOCRT(llrint)( -42.25), -43);
|
---|
2320 | CHECK_LLONG(RT_NOCRT(llrint)( +42.25), +42);
|
---|
2321 | CHECK_LLONG(RT_NOCRT(llrint)( -42.75), -43);
|
---|
2322 | CHECK_LLONG(RT_NOCRT(llrint)( +42.75), +42);
|
---|
2323 | CHECK_LLONG(RT_NOCRT(llrint)(+1234.60958634e+20), LLONG_MIN);
|
---|
2324 | CHECK_LLONG(RT_NOCRT(llrint)(-1234.60958634e+20), LLONG_MIN);
|
---|
2325 | CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e+20), LLONG_MIN);
|
---|
2326 | CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e-10), -1);
|
---|
2327 | CHECK_LLONG(RT_NOCRT(llrint)( -2.1984e-310), -1); /* subnormal */
|
---|
2328 | CHECK_LLONG(RT_NOCRT(llrint)(-INFINITY), LLONG_MIN);
|
---|
2329 | CHECK_LLONG(RT_NOCRT(llrint)(+INFINITY), LLONG_MIN);
|
---|
2330 | CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble(NULL, true)),LLONG_MIN);
|
---|
2331 | CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble("s", false)),LLONG_MIN);
|
---|
2332 | CHECK_LLONG_SAME(llrint,( -0.0));
|
---|
2333 | CHECK_LLONG_SAME(llrint,( +0.0));
|
---|
2334 | CHECK_LLONG_SAME(llrint,( +42.25));
|
---|
2335 | CHECK_LLONG_SAME(llrint,( -42.25));
|
---|
2336 | CHECK_LLONG_SAME(llrint,( +42.75));
|
---|
2337 | CHECK_LLONG_SAME(llrint,( -42.75));
|
---|
2338 | CHECK_LLONG_SAME(llrint,( +22.5));
|
---|
2339 | CHECK_LLONG_SAME(llrint,( -22.5));
|
---|
2340 | CHECK_LLONG_SAME(llrint,( +23.5));
|
---|
2341 | CHECK_LLONG_SAME(llrint,( -23.5));
|
---|
2342 | CHECK_LLONG_SAME(llrint,( +42.25e+6));
|
---|
2343 | CHECK_LLONG_SAME(llrint,( -42.25e+6));
|
---|
2344 | CHECK_LLONG_SAME(llrint,( -1234.499999e-10));
|
---|
2345 | CHECK_LLONG_SAME(llrint,( -2.1984e-310)); /* subnormal */
|
---|
2346 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
2347 | CHECK_LLONG_SAME(llrint,(+1234.60958634e+20));
|
---|
2348 | CHECK_LLONG_SAME(llrint,(-1234.60958634e+20));
|
---|
2349 | CHECK_LLONG_SAME(llrint,( -1234.499999e+20));
|
---|
2350 | CHECK_LLONG_SAME(llrint,(-INFINITY));
|
---|
2351 | CHECK_LLONG_SAME(llrint,(+INFINITY));
|
---|
2352 | CHECK_LLONG_SAME(llrint,(RTStrNanDouble(NULL, true)));
|
---|
2353 | CHECK_LLONG_SAME(llrint,(RTStrNanDouble("s", false)));
|
---|
2354 | #endif
|
---|
2355 |
|
---|
2356 | CHECK_LLONG(RT_NOCRT(llrintf)( +0.0f), 0);
|
---|
2357 | CHECK_LLONG(RT_NOCRT(llrintf)( -0.0f), 0);
|
---|
2358 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.0f), -42);
|
---|
2359 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.5f), -43);
|
---|
2360 | CHECK_LLONG(RT_NOCRT(llrintf)( +42.5f), +42);
|
---|
2361 | CHECK_LLONG(RT_NOCRT(llrintf)( -43.5f), -44);
|
---|
2362 | CHECK_LLONG(RT_NOCRT(llrintf)( +43.5f), +43);
|
---|
2363 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.25f), -43);
|
---|
2364 | CHECK_LLONG(RT_NOCRT(llrintf)( +42.25f), +42);
|
---|
2365 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.75f), -43);
|
---|
2366 | CHECK_LLONG(RT_NOCRT(llrintf)( +42.75f), +42);
|
---|
2367 | CHECK_LLONG(RT_NOCRT(llrintf)(+1234.60958634e+20f), LLONG_MIN);
|
---|
2368 | CHECK_LLONG(RT_NOCRT(llrintf)(-1234.60958634e+20f), LLONG_MIN);
|
---|
2369 | CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e+20f), LLONG_MIN);
|
---|
2370 | CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e-10f), -1);
|
---|
2371 | CHECK_LLONG(RT_NOCRT(llrintf)( -2.1984e-40f), -1); /* subnormal */
|
---|
2372 | CHECK_LLONG(RT_NOCRT(llrintf)(-INFINITY), LLONG_MIN);
|
---|
2373 | CHECK_LLONG(RT_NOCRT(llrintf)(+INFINITY), LLONG_MIN);
|
---|
2374 | CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble(NULL, true)), LLONG_MIN);
|
---|
2375 | CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble("s", false)), LLONG_MIN);
|
---|
2376 | CHECK_LLONG_SAME(llrintf,( -0.0f));
|
---|
2377 | CHECK_LLONG_SAME(llrintf,( +0.0f));
|
---|
2378 | CHECK_LLONG_SAME(llrintf,( +42.25f));
|
---|
2379 | CHECK_LLONG_SAME(llrintf,( -42.25f));
|
---|
2380 | CHECK_LLONG_SAME(llrintf,( +42.75f));
|
---|
2381 | CHECK_LLONG_SAME(llrintf,( -42.75f));
|
---|
2382 | CHECK_LLONG_SAME(llrintf,( +22.5f));
|
---|
2383 | CHECK_LLONG_SAME(llrintf,( -22.5f));
|
---|
2384 | CHECK_LLONG_SAME(llrintf,( +23.5f));
|
---|
2385 | CHECK_LLONG_SAME(llrintf,( -23.5f));
|
---|
2386 | CHECK_LLONG_SAME(llrintf,( +42.25e+6f));
|
---|
2387 | CHECK_LLONG_SAME(llrintf,( -42.25e+6f));
|
---|
2388 | CHECK_LLONG_SAME(llrintf,( -1234.499999e-10f));
|
---|
2389 | CHECK_LLONG_SAME(llrintf,( -2.1984e-40f)); /* subnormal */
|
---|
2390 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
2391 | CHECK_LLONG_SAME(llrintf,(+1234.60958634e+20f));
|
---|
2392 | CHECK_LLONG_SAME(llrintf,(-1234.60958634e+20f));
|
---|
2393 | CHECK_LLONG_SAME(llrintf,( -1234.499999e+20f));
|
---|
2394 | CHECK_LLONG_SAME(llrintf,(-INFINITY));
|
---|
2395 | CHECK_LLONG_SAME(llrintf,(+INFINITY));
|
---|
2396 | CHECK_LLONG_SAME(llrintf,(RTStrNanFloat(NULL, true)));
|
---|
2397 | CHECK_LLONG_SAME(llrintf,(RTStrNanFloat("s", false)));
|
---|
2398 | #endif
|
---|
2399 |
|
---|
2400 | /*
|
---|
2401 | * Round towards ZERO.
|
---|
2402 | */
|
---|
2403 | RT_NOCRT(fesetround)(FE_TOWARDZERO);
|
---|
2404 |
|
---|
2405 | CHECK_LLONG(RT_NOCRT(llrint)( +0.0), 0);
|
---|
2406 | CHECK_LLONG(RT_NOCRT(llrint)( -0.0), 0);
|
---|
2407 | CHECK_LLONG(RT_NOCRT(llrint)( -42.0), -42);
|
---|
2408 | CHECK_LLONG(RT_NOCRT(llrint)( -42.5), -42);
|
---|
2409 | CHECK_LLONG(RT_NOCRT(llrint)( +42.5), +42);
|
---|
2410 | CHECK_LLONG(RT_NOCRT(llrint)( -43.5), -43);
|
---|
2411 | CHECK_LLONG(RT_NOCRT(llrint)( +43.5), +43);
|
---|
2412 | CHECK_LLONG(RT_NOCRT(llrint)( -42.25), -42);
|
---|
2413 | CHECK_LLONG(RT_NOCRT(llrint)( +42.25), +42);
|
---|
2414 | CHECK_LLONG(RT_NOCRT(llrint)( -42.75), -42);
|
---|
2415 | CHECK_LLONG(RT_NOCRT(llrint)( +42.75), +42);
|
---|
2416 | CHECK_LLONG(RT_NOCRT(llrint)(+1234.60958634e+20), LLONG_MIN);
|
---|
2417 | CHECK_LLONG(RT_NOCRT(llrint)(-1234.60958634e+20), LLONG_MIN);
|
---|
2418 | CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e+20), LLONG_MIN);
|
---|
2419 | CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e-10), 0);
|
---|
2420 | CHECK_LLONG(RT_NOCRT(llrint)( -2.1984e-310), 0); /* subnormal */
|
---|
2421 | CHECK_LLONG(RT_NOCRT(llrint)(-INFINITY), LLONG_MIN);
|
---|
2422 | CHECK_LLONG(RT_NOCRT(llrint)(+INFINITY), LLONG_MIN);
|
---|
2423 | CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble(NULL, true)),LLONG_MIN);
|
---|
2424 | CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble("s", false)),LLONG_MIN);
|
---|
2425 | CHECK_LLONG_SAME(llrint,( -0.0));
|
---|
2426 | CHECK_LLONG_SAME(llrint,( +0.0));
|
---|
2427 | CHECK_LLONG_SAME(llrint,( +42.25));
|
---|
2428 | CHECK_LLONG_SAME(llrint,( -42.25));
|
---|
2429 | CHECK_LLONG_SAME(llrint,( +42.75));
|
---|
2430 | CHECK_LLONG_SAME(llrint,( -42.75));
|
---|
2431 | CHECK_LLONG_SAME(llrint,( +22.5));
|
---|
2432 | CHECK_LLONG_SAME(llrint,( -22.5));
|
---|
2433 | CHECK_LLONG_SAME(llrint,( +23.5));
|
---|
2434 | CHECK_LLONG_SAME(llrint,( -23.5));
|
---|
2435 | CHECK_LLONG_SAME(llrint,( +42.25e+6));
|
---|
2436 | CHECK_LLONG_SAME(llrint,( -42.25e+6));
|
---|
2437 | CHECK_LLONG_SAME(llrint,( -1234.499999e-10));
|
---|
2438 | CHECK_LLONG_SAME(llrint,( -2.1984e-310)); /* subnormal */
|
---|
2439 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
2440 | CHECK_LLONG_SAME(llrint,(+1234.60958634e+20));
|
---|
2441 | CHECK_LLONG_SAME(llrint,(-1234.60958634e+20));
|
---|
2442 | CHECK_LLONG_SAME(llrint,( -1234.499999e+20));
|
---|
2443 | CHECK_LLONG_SAME(llrint,(-INFINITY));
|
---|
2444 | CHECK_LLONG_SAME(llrint,(+INFINITY));
|
---|
2445 | CHECK_LLONG_SAME(llrint,(RTStrNanDouble(NULL, true)));
|
---|
2446 | CHECK_LLONG_SAME(llrint,(RTStrNanDouble("s", false)));
|
---|
2447 | #endif
|
---|
2448 |
|
---|
2449 | CHECK_LLONG(RT_NOCRT(llrintf)( +0.0f), 0);
|
---|
2450 | CHECK_LLONG(RT_NOCRT(llrintf)( -0.0f), 0);
|
---|
2451 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.0f), -42);
|
---|
2452 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.5f), -42);
|
---|
2453 | CHECK_LLONG(RT_NOCRT(llrintf)( +42.5f), +42);
|
---|
2454 | CHECK_LLONG(RT_NOCRT(llrintf)( -43.5f), -43);
|
---|
2455 | CHECK_LLONG(RT_NOCRT(llrintf)( +43.5f), +43);
|
---|
2456 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.25f), -42);
|
---|
2457 | CHECK_LLONG(RT_NOCRT(llrintf)( +42.25f), +42);
|
---|
2458 | CHECK_LLONG(RT_NOCRT(llrintf)( -42.75f), -42);
|
---|
2459 | CHECK_LLONG(RT_NOCRT(llrintf)( +42.75f), +42);
|
---|
2460 | CHECK_LLONG(RT_NOCRT(llrintf)(+1234.60958634e+20f), LLONG_MIN);
|
---|
2461 | CHECK_LLONG(RT_NOCRT(llrintf)(-1234.60958634e+20f), LLONG_MIN);
|
---|
2462 | CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e+20f), LLONG_MIN);
|
---|
2463 | CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e-10f), 0);
|
---|
2464 | CHECK_LLONG(RT_NOCRT(llrintf)( -2.1984e-40f), 0); /* subnormal */
|
---|
2465 | CHECK_LLONG(RT_NOCRT(llrintf)(-INFINITY), LLONG_MIN);
|
---|
2466 | CHECK_LLONG(RT_NOCRT(llrintf)(+INFINITY), LLONG_MIN);
|
---|
2467 | CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble(NULL, true)), LLONG_MIN);
|
---|
2468 | CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble("s", false)), LLONG_MIN);
|
---|
2469 | CHECK_LLONG_SAME(llrintf,( -0.0f));
|
---|
2470 | CHECK_LLONG_SAME(llrintf,( +0.0f));
|
---|
2471 | CHECK_LLONG_SAME(llrintf,( +42.25f));
|
---|
2472 | CHECK_LLONG_SAME(llrintf,( -42.25f));
|
---|
2473 | CHECK_LLONG_SAME(llrintf,( +42.75f));
|
---|
2474 | CHECK_LLONG_SAME(llrintf,( -42.75f));
|
---|
2475 | CHECK_LLONG_SAME(llrintf,( +22.5f));
|
---|
2476 | CHECK_LLONG_SAME(llrintf,( -22.5f));
|
---|
2477 | CHECK_LLONG_SAME(llrintf,( +23.5f));
|
---|
2478 | CHECK_LLONG_SAME(llrintf,( -23.5f));
|
---|
2479 | CHECK_LLONG_SAME(llrintf,( +42.25e+6f));
|
---|
2480 | CHECK_LLONG_SAME(llrintf,( -42.25e+6f));
|
---|
2481 | CHECK_LLONG_SAME(llrintf,( -1234.499999e-10f));
|
---|
2482 | CHECK_LLONG_SAME(llrintf,( -2.1984e-40f)); /* subnormal */
|
---|
2483 | #if 0 /* Undefined, we disagree with UCRT on windows. */
|
---|
2484 | CHECK_LLONG_SAME(llrintf,(+1234.60958634e+20f));
|
---|
2485 | CHECK_LLONG_SAME(llrintf,(-1234.60958634e+20f));
|
---|
2486 | CHECK_LLONG_SAME(llrintf,( -1234.499999e+20f));
|
---|
2487 | CHECK_LLONG_SAME(llrintf,(-INFINITY));
|
---|
2488 | CHECK_LLONG_SAME(llrintf,(+INFINITY));
|
---|
2489 | CHECK_LLONG_SAME(llrintf,(RTStrNanFloat(NULL, true)));
|
---|
2490 | CHECK_LLONG_SAME(llrintf,(RTStrNanFloat("s", false)));
|
---|
2491 | #endif
|
---|
2492 |
|
---|
2493 | RT_NOCRT(fesetround)(iSavedMode);
|
---|
2494 | }
|
---|
2495 |
|
---|
2496 |
|
---|
2497 | void testExp()
|
---|
2498 | {
|
---|
2499 | RTTestSub(g_hTest, "exp[f]");
|
---|
2500 |
|
---|
2501 | CHECK_DBL( RT_NOCRT(exp)( +1.0), M_E);
|
---|
2502 | CHECK_DBL_RANGE( RT_NOCRT(exp)( +2.0), M_E * M_E, 0.000000000000001);
|
---|
2503 | CHECK_DBL( RT_NOCRT(exp)( +INFINITY), +INFINITY);
|
---|
2504 | CHECK_DBL( RT_NOCRT(exp)( -INFINITY), +0.0);
|
---|
2505 | CHECK_DBL( RT_NOCRT(exp)( +0.0), +1.0);
|
---|
2506 | CHECK_DBL( RT_NOCRT(exp)( -0.0), +1.0);
|
---|
2507 | CHECK_DBL_SAME( exp,( +0.0));
|
---|
2508 | CHECK_DBL_SAME( exp,( -0.0));
|
---|
2509 | CHECK_DBL_SAME( exp,( +1.0));
|
---|
2510 | CHECK_DBL_SAME( exp,( +2.0));
|
---|
2511 | CHECK_DBL_SAME( exp,( -1.0));
|
---|
2512 | CHECK_DBL_APPROX_SAME( exp,( +0.5), 1);
|
---|
2513 | CHECK_DBL_APPROX_SAME( exp,( -0.5), 1);
|
---|
2514 | CHECK_DBL_APPROX_SAME( exp,( +1.5), 1);
|
---|
2515 | CHECK_DBL_APPROX_SAME( exp,( -1.5), 1);
|
---|
2516 | CHECK_DBL_APPROX_SAME( exp,( +3.25), 16);
|
---|
2517 | CHECK_DBL_APPROX_SAME( exp,( 99.2559430), 16);
|
---|
2518 | CHECK_DBL_APPROX_SAME( exp,( -99.2559430), 32);
|
---|
2519 | CHECK_DBL_APPROX_SAME( exp,( +305.2559430), 128);
|
---|
2520 | CHECK_DBL_APPROX_SAME( exp,( -305.2559430), 128);
|
---|
2521 | CHECK_DBL_APPROX_SAME( exp,( +309.99884), 128);
|
---|
2522 | CHECK_DBL_APPROX_SAME( exp,( -309.111048), 128);
|
---|
2523 | CHECK_DBL_APPROX_SAME( exp,( +999.864597634), 1);
|
---|
2524 | CHECK_DBL_APPROX_SAME( exp,( -999.098234837), 1);
|
---|
2525 | CHECK_DBL_SAME( exp,( +DBL_MAX));
|
---|
2526 | CHECK_DBL_SAME( exp,( -DBL_MAX));
|
---|
2527 | CHECK_DBL_SAME( exp,( -DBL_MIN));
|
---|
2528 | CHECK_DBL_SAME( exp,( +DBL_MIN));
|
---|
2529 | CHECK_DBL_SAME( exp,( +INFINITY));
|
---|
2530 | CHECK_DBL_SAME( exp,( -INFINITY));
|
---|
2531 | CHECK_DBL_SAME( exp,(RTStrNanDouble(NULL, false)));
|
---|
2532 | CHECK_DBL_SAME( exp,(RTStrNanDouble("ab305f", true)));
|
---|
2533 | CHECK_DBL_SAME_RELAXED_NAN(exp,(RTStrNanDouble("fffffffff_signaling", true)));
|
---|
2534 | CHECK_DBL_SAME_RELAXED_NAN(exp,(RTStrNanDouble("7777777777778_sig", false)));
|
---|
2535 |
|
---|
2536 | CHECK_FLT( RT_NOCRT(expf)( +1.0f), (float)M_E);
|
---|
2537 | CHECK_FLT( RT_NOCRT(expf)( +2.0f), (float)(M_E * M_E));
|
---|
2538 | CHECK_FLT( RT_NOCRT(expf)(+(float)INFINITY),+(float)INFINITY);
|
---|
2539 | CHECK_FLT( RT_NOCRT(expf)(-(float)INFINITY),+0.0f);
|
---|
2540 | CHECK_FLT( RT_NOCRT(expf)( +0.0f), +1.0f);
|
---|
2541 | CHECK_FLT( RT_NOCRT(expf)( -0.0f), +1.0f);
|
---|
2542 | CHECK_FLT_SAME( expf,( +0.0f));
|
---|
2543 | CHECK_FLT_SAME( expf,( -0.0f));
|
---|
2544 | CHECK_FLT_SAME( expf,( +1.0f));
|
---|
2545 | CHECK_FLT_SAME( expf,( +2.0f));
|
---|
2546 | CHECK_FLT_SAME( expf,( -1.0f));
|
---|
2547 | CHECK_FLT_SAME( expf,( +0.5f));
|
---|
2548 | CHECK_FLT_SAME( expf,( -0.5f));
|
---|
2549 | CHECK_FLT_SAME( expf,( +1.5f));
|
---|
2550 | CHECK_FLT_SAME( expf,( -1.5f));
|
---|
2551 | CHECK_FLT_SAME( expf,( +3.25f));
|
---|
2552 | CHECK_FLT_SAME( expf,( 99.2559430f));
|
---|
2553 | CHECK_FLT_SAME( expf,( -99.2559430f));
|
---|
2554 | CHECK_FLT_SAME( expf,( +305.2559430f));
|
---|
2555 | CHECK_FLT_SAME( expf,( -305.2559430f));
|
---|
2556 | CHECK_FLT_SAME( expf,( +309.99884f));
|
---|
2557 | CHECK_FLT_SAME( expf,( -309.111048f));
|
---|
2558 | CHECK_FLT_SAME( expf,( +999.864597634f));
|
---|
2559 | CHECK_FLT_SAME( expf,( -999.098234837f));
|
---|
2560 | CHECK_FLT_SAME( expf,( +FLT_MAX));
|
---|
2561 | CHECK_FLT_SAME( expf,( -FLT_MAX));
|
---|
2562 | CHECK_FLT_SAME( expf,( -FLT_MIN));
|
---|
2563 | CHECK_FLT_SAME( expf,( +FLT_MIN));
|
---|
2564 | CHECK_FLT_SAME( expf,(+(float)INFINITY));
|
---|
2565 | CHECK_FLT_SAME( expf,(-(float)INFINITY));
|
---|
2566 | CHECK_FLT_SAME( expf,(RTStrNanFloat(NULL, false)));
|
---|
2567 | CHECK_FLT_SAME( expf,(RTStrNanFloat("ab305f", true)));
|
---|
2568 | CHECK_FLT_SAME_RELAXED_NAN(expf,(RTStrNanFloat("fffffffff_signaling", true)));
|
---|
2569 | CHECK_FLT_SAME_RELAXED_NAN(expf,(RTStrNanFloat("7777777777778_sig", false)));
|
---|
2570 | }
|
---|
2571 |
|
---|
2572 |
|
---|
2573 | void testExp2()
|
---|
2574 | {
|
---|
2575 | RTTestSub(g_hTest, "exp2[f]");
|
---|
2576 |
|
---|
2577 | CHECK_DBL( RT_NOCRT(exp2)( 1.0), 2.0);
|
---|
2578 | CHECK_DBL( RT_NOCRT(exp2)( 2.0), 4.0);
|
---|
2579 | CHECK_DBL( RT_NOCRT(exp2)( 32.0), 4294967296.0);
|
---|
2580 | CHECK_DBL( RT_NOCRT(exp2)( -1.0), 0.5);
|
---|
2581 | CHECK_DBL( RT_NOCRT(exp2)( -3.0), 0.125);
|
---|
2582 | CHECK_DBL_SAME( exp2,( 0.0));
|
---|
2583 | CHECK_DBL_SAME( exp2,( 1.0));
|
---|
2584 | CHECK_DBL_SAME( exp2,( 2.0));
|
---|
2585 | CHECK_DBL_SAME( exp2,( -1.0));
|
---|
2586 | CHECK_DBL_APPROX_SAME(exp2,( +0.5), 1);
|
---|
2587 | CHECK_DBL_APPROX_SAME(exp2,( -0.5), 1);
|
---|
2588 | CHECK_DBL_APPROX_SAME(exp2,( +1.5), 1);
|
---|
2589 | CHECK_DBL_APPROX_SAME(exp2,( -1.5), 1);
|
---|
2590 | CHECK_DBL_APPROX_SAME(exp2,( +3.25), 1);
|
---|
2591 | CHECK_DBL_APPROX_SAME(exp2,( 99.2559430), 1);
|
---|
2592 | CHECK_DBL_APPROX_SAME(exp2,( -99.2559430), 1);
|
---|
2593 | CHECK_DBL_APPROX_SAME(exp2,( +305.2559430), 1);
|
---|
2594 | CHECK_DBL_APPROX_SAME(exp2,( -305.2559430), 1);
|
---|
2595 | CHECK_DBL_APPROX_SAME(exp2,( +309.99884), 1);
|
---|
2596 | CHECK_DBL_APPROX_SAME(exp2,( -309.111048), 1);
|
---|
2597 | CHECK_DBL_APPROX_SAME(exp2,(+999.864597634), 1);
|
---|
2598 | CHECK_DBL_APPROX_SAME(exp2,(-999.098234837), 1);
|
---|
2599 | CHECK_DBL_SAME( exp2,( +INFINITY));
|
---|
2600 | CHECK_DBL_SAME( exp2,( -INFINITY));
|
---|
2601 | CHECK_DBL_SAME( exp2,( nan("1")));
|
---|
2602 | CHECK_DBL_SAME( exp2,(RTStrNanDouble("ab305f", true)));
|
---|
2603 | CHECK_DBL_SAME( exp2,(RTStrNanDouble("fffffffff_signaling", true)));
|
---|
2604 | CHECK_DBL_SAME( exp2,(RTStrNanDouble("7777777777778_sig", false)));
|
---|
2605 |
|
---|
2606 |
|
---|
2607 | CHECK_FLT( RT_NOCRT(exp2f)( 1.0f), 2.0f);
|
---|
2608 | CHECK_FLT( RT_NOCRT(exp2f)( 2.0f), 4.0f);
|
---|
2609 | CHECK_FLT( RT_NOCRT(exp2f)( 32.0f), 4294967296.0f);
|
---|
2610 | CHECK_FLT( RT_NOCRT(exp2f)( -1.0f), 0.5f);
|
---|
2611 | CHECK_FLT( RT_NOCRT(exp2f)( -3.0f), 0.125f);
|
---|
2612 | CHECK_FLT_SAME( exp2f,( 0.0f));
|
---|
2613 | CHECK_FLT_SAME( exp2f,(+(float)INFINITY));
|
---|
2614 | CHECK_FLT_SAME( exp2f,(-(float)INFINITY));
|
---|
2615 | CHECK_FLT_SAME( exp2f,( nan("1")));
|
---|
2616 | CHECK_FLT_SAME( exp2f,(RTStrNanFloat("ab305f", true)));
|
---|
2617 | CHECK_FLT_SAME( exp2f,(RTStrNanFloat("3fffff_signaling", true)));
|
---|
2618 | CHECK_FLT_SAME( exp2f,(RTStrNanFloat("79778_sig", false)));
|
---|
2619 | CHECK_FLT_SAME( exp2f,( 1.0f));
|
---|
2620 | CHECK_FLT_SAME( exp2f,( 2.0f));
|
---|
2621 | CHECK_FLT_SAME( exp2f,( -1.0f));
|
---|
2622 | CHECK_FLT_APPROX_SAME(exp2f,( +0.5f), 1);
|
---|
2623 | CHECK_FLT_APPROX_SAME(exp2f,( -0.5f), 1);
|
---|
2624 | CHECK_FLT_APPROX_SAME(exp2f,( +1.5f), 1);
|
---|
2625 | CHECK_FLT_APPROX_SAME(exp2f,( -1.5f), 1);
|
---|
2626 | CHECK_FLT_APPROX_SAME(exp2f,( +3.25f), 1);
|
---|
2627 | CHECK_FLT_APPROX_SAME(exp2f,( 99.25594f), 1);
|
---|
2628 | CHECK_FLT_APPROX_SAME(exp2f,( -99.25594f), 1);
|
---|
2629 | CHECK_FLT_APPROX_SAME(exp2f,( +305.25594f), 1);
|
---|
2630 | CHECK_FLT_APPROX_SAME(exp2f,( -305.25594f), 1);
|
---|
2631 | CHECK_FLT_APPROX_SAME(exp2f,( +309.99884f), 1);
|
---|
2632 | CHECK_FLT_APPROX_SAME(exp2f,( -309.111048f), 1);
|
---|
2633 | CHECK_FLT_APPROX_SAME(exp2f,( +999.86459f), 1);
|
---|
2634 | CHECK_FLT_APPROX_SAME(exp2f,( -999.09823f), 1);
|
---|
2635 | }
|
---|
2636 |
|
---|
2637 |
|
---|
2638 | void testLdExp()
|
---|
2639 | {
|
---|
2640 | RTTestSub(g_hTest, "ldexp[f]");
|
---|
2641 |
|
---|
2642 | CHECK_DBL(RT_NOCRT(ldexp)(1.0, 1), 2.0);
|
---|
2643 | CHECK_DBL(RT_NOCRT(ldexp)(1.0, 2), 4.0);
|
---|
2644 | CHECK_DBL(RT_NOCRT(ldexp)(1.0, 32), 4294967296.0);
|
---|
2645 | CHECK_DBL(RT_NOCRT(ldexp)(2.0, 31), 4294967296.0);
|
---|
2646 | CHECK_DBL(RT_NOCRT(ldexp)(0.5, 33), 4294967296.0);
|
---|
2647 | CHECK_DBL(RT_NOCRT(ldexp)(1.0, -1), 0.5);
|
---|
2648 | CHECK_DBL(RT_NOCRT(ldexp)(1.0, -3), 0.125);
|
---|
2649 | CHECK_DBL_SAME(ldexp, (0.0, 0));
|
---|
2650 | CHECK_DBL_SAME(ldexp, (+INFINITY, 1));
|
---|
2651 | CHECK_DBL_SAME(ldexp, (+INFINITY, 2));
|
---|
2652 | CHECK_DBL_SAME(ldexp, (-INFINITY, 1));
|
---|
2653 | CHECK_DBL_SAME(ldexp, (-INFINITY, 2));
|
---|
2654 | CHECK_DBL_SAME(ldexp, (nan("1"), 1));
|
---|
2655 | CHECK_DBL_SAME(ldexp, (RTStrNanDouble("ab305f", true), 2));
|
---|
2656 | CHECK_DBL_SAME(ldexp, (RTStrNanDouble("fffffffff_signaling", true), 3));
|
---|
2657 | CHECK_DBL_SAME(ldexp, (RTStrNanDouble("7777777777778_sig", false), -4));
|
---|
2658 | CHECK_DBL_SAME(ldexp, ( 1.0, 1));
|
---|
2659 | CHECK_DBL_SAME(ldexp, ( 2.0, 2));
|
---|
2660 | CHECK_DBL_SAME(ldexp, ( -1.0, -1));
|
---|
2661 | CHECK_DBL_SAME(ldexp, ( +0.5, 63));
|
---|
2662 | CHECK_DBL_SAME(ldexp, ( -0.5, -73));
|
---|
2663 | CHECK_DBL_SAME(ldexp, ( +1.5, -88));
|
---|
2664 | CHECK_DBL_SAME(ldexp, ( -1.5, 99));
|
---|
2665 | CHECK_DBL_SAME(ldexp, ( +3.25, -102));
|
---|
2666 | CHECK_DBL_SAME(ldexp, ( 99.2559430, -256));
|
---|
2667 | CHECK_DBL_SAME(ldexp, ( -99.2559430, 256));
|
---|
2668 | CHECK_DBL_SAME(ldexp, ( +305.2559430, 34));
|
---|
2669 | CHECK_DBL_SAME(ldexp, ( -305.2559430, 79));
|
---|
2670 | CHECK_DBL_SAME(ldexp, ( +309.99884, -99));
|
---|
2671 | CHECK_DBL_SAME(ldexp, ( -309.111048, -38));
|
---|
2672 | CHECK_DBL_SAME(ldexp, (+999.864597634, -21));
|
---|
2673 | CHECK_DBL_SAME(ldexp, (-999.098234837, 21));
|
---|
2674 |
|
---|
2675 | CHECK_FLT(RT_NOCRT(ldexpf)(1.0f, 1), 2.0f);
|
---|
2676 | CHECK_FLT(RT_NOCRT(ldexpf)(1.0f, 2), 4.0f);
|
---|
2677 | CHECK_FLT(RT_NOCRT(ldexpf)(1.0f, 32), 4294967296.0f);
|
---|
2678 | CHECK_FLT(RT_NOCRT(ldexpf)(2.0f, 31), 4294967296.0f);
|
---|
2679 | CHECK_FLT(RT_NOCRT(ldexpf)(0.5f, 33), 4294967296.0f);
|
---|
2680 | CHECK_FLT(RT_NOCRT(ldexpf)(1.0f, -1), 0.5f);
|
---|
2681 | CHECK_FLT(RT_NOCRT(ldexpf)(1.0f, -3), 0.125f);
|
---|
2682 | CHECK_FLT_SAME(ldexpf, (0.0f, 0));
|
---|
2683 | CHECK_FLT_SAME(ldexpf, (+INFINITY, 1));
|
---|
2684 | CHECK_FLT_SAME(ldexpf, (+INFINITY, 2));
|
---|
2685 | CHECK_FLT_SAME(ldexpf, (-INFINITY, 1));
|
---|
2686 | CHECK_FLT_SAME(ldexpf, (-INFINITY, 2));
|
---|
2687 | CHECK_FLT_SAME(ldexpf, (nan("1"), 1));
|
---|
2688 | CHECK_FLT_SAME(ldexpf, (RTStrNanDouble("ab305f", true), 2));
|
---|
2689 | CHECK_FLT_SAME(ldexpf, (RTStrNanDouble("fffffffff_signaling", true), 3));
|
---|
2690 | CHECK_FLT_SAME(ldexpf, (RTStrNanDouble("7777777777778_sig", false), -4));
|
---|
2691 | CHECK_FLT_SAME(ldexpf, ( 1.0f, 1));
|
---|
2692 | CHECK_FLT_SAME(ldexpf, ( 2.0f, 2));
|
---|
2693 | CHECK_FLT_SAME(ldexpf, ( -1.0f, -1));
|
---|
2694 | CHECK_FLT_SAME(ldexpf, ( +0.5f, 63));
|
---|
2695 | CHECK_FLT_SAME(ldexpf, ( -0.5f, -73));
|
---|
2696 | CHECK_FLT_SAME(ldexpf, ( +1.5f, -88));
|
---|
2697 | CHECK_FLT_SAME(ldexpf, ( -1.5f, 99));
|
---|
2698 | CHECK_FLT_SAME(ldexpf, ( +3.25f, -102));
|
---|
2699 | CHECK_FLT_SAME(ldexpf, ( 99.2559430f, -256));
|
---|
2700 | CHECK_FLT_SAME(ldexpf, ( -99.2559430f, 256));
|
---|
2701 | CHECK_FLT_SAME(ldexpf, ( +305.2559430f, 34));
|
---|
2702 | CHECK_FLT_SAME(ldexpf, ( -305.2559430f, 79));
|
---|
2703 | CHECK_FLT_SAME(ldexpf, ( +309.99884f, -99));
|
---|
2704 | CHECK_FLT_SAME(ldexpf, ( -309.111048f, -38));
|
---|
2705 | CHECK_FLT_SAME(ldexpf, (+999.864597634f, -21));
|
---|
2706 | CHECK_FLT_SAME(ldexpf, (-999.098234837f, 21));
|
---|
2707 |
|
---|
2708 | }
|
---|
2709 |
|
---|
2710 |
|
---|
2711 | void testPow()
|
---|
2712 | {
|
---|
2713 | RTTestSub(g_hTest, "pow[f]");
|
---|
2714 |
|
---|
2715 | /*
|
---|
2716 | * pow
|
---|
2717 | */
|
---|
2718 | CHECK_DBL( RT_NOCRT(pow)( +1.0, +1.0), +1.0);
|
---|
2719 | CHECK_DBL( RT_NOCRT(pow)( +2.0, +1.0), +2.0);
|
---|
2720 | CHECK_DBL( RT_NOCRT(pow)( +2.0, +2.0), +4.0);
|
---|
2721 | CHECK_DBL( RT_NOCRT(pow)( +2.0, +43.0), +8796093022208.0);
|
---|
2722 |
|
---|
2723 | /* special values: */
|
---|
2724 | CHECK_DBL( RT_NOCRT(pow)( +1.0, 43.0), +1.0); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2725 | CHECK_DBL( RT_NOCRT(pow)( +1.0, +0.0), +1.0); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2726 | CHECK_DBL( RT_NOCRT(pow)( +1.0, -0.0), +1.0); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2727 | CHECK_DBL( RT_NOCRT(pow)( +1.0, -34.5534), +1.0); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2728 | CHECK_DBL( RT_NOCRT(pow)( +1.0, +1.0e+128), +1.0); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2729 | CHECK_DBL( RT_NOCRT(pow)( +1.0, -1.0e+128), +1.0); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2730 | CHECK_DBL( RT_NOCRT(pow)( +1.0, +INFINITY), +1.0); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2731 | CHECK_DBL( RT_NOCRT(pow)( +1.0, -INFINITY), +1.0); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2732 | CHECK_DBL( RT_NOCRT(pow)( +1.0, RTStrNanDouble(NULL, true)), +1.0); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2733 | CHECK_DBL( RT_NOCRT(pow)( +1.0, RTStrNanDouble("s", false)), +1.0); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2734 | CHECK_DBL( RT_NOCRT(pow)( -1.0, +INFINITY), +1.0); /* 10. Exponent = +/-Inf and base = -1: Return 1.0 */
|
---|
2735 | CHECK_DBL( RT_NOCRT(pow)( +0.9, -INFINITY), +INFINITY); /* 11. Exponent = -Inf and |base| < 1: Return +Inf */
|
---|
2736 | CHECK_DBL( RT_NOCRT(pow)( +0.3490, -INFINITY), +INFINITY); /* 11. Exponent = -Inf and |base| < 1: Return +Inf */
|
---|
2737 | CHECK_DBL( RT_NOCRT(pow)( -0.9, -INFINITY), +INFINITY); /* 11. Exponent = -Inf and |base| < 1: Return +Inf */
|
---|
2738 | CHECK_DBL( RT_NOCRT(pow)( -0.165634, -INFINITY), +INFINITY); /* 11. Exponent = -Inf and |base| < 1: Return +Inf */
|
---|
2739 | CHECK_DBL( RT_NOCRT(pow)( -1.000001, -INFINITY), +0.0); /* 12. Exponent = -Inf and |base| > 1: Return +0 */
|
---|
2740 | CHECK_DBL( RT_NOCRT(pow)( +1.000001, -INFINITY), +0.0); /* 12. Exponent = -Inf and |base| > 1: Return +0 */
|
---|
2741 | CHECK_DBL( RT_NOCRT(pow)( +42.1, -INFINITY), +0.0); /* 12. Exponent = -Inf and |base| > 1: Return +0 */
|
---|
2742 | CHECK_DBL( RT_NOCRT(pow)( -42.1e+34, -INFINITY), +0.0); /* 12. Exponent = -Inf and |base| > 1: Return +0 */
|
---|
2743 | CHECK_DBL( RT_NOCRT(pow)( +42.1e+99, -INFINITY), +0.0); /* 12. Exponent = -Inf and |base| > 1: Return +0 */
|
---|
2744 | CHECK_DBL( RT_NOCRT(pow)( +0.8, +INFINITY), +0.0); /* 13. Exponent = +Inf and |base| < 1: Return +0 */
|
---|
2745 | CHECK_DBL( RT_NOCRT(pow)( -0.8, +INFINITY), +0.0); /* 13. Exponent = +Inf and |base| < 1: Return +0 */
|
---|
2746 | CHECK_DBL( RT_NOCRT(pow)( +1.000003, +INFINITY), +INFINITY); /* 14. Exponent = +Inf and |base| > 1: Return +Inf */
|
---|
2747 | CHECK_DBL( RT_NOCRT(pow)( -1.000003, +INFINITY), +INFINITY); /* 14. Exponent = +Inf and |base| > 1: Return +Inf */
|
---|
2748 | CHECK_DBL( RT_NOCRT(pow)( +42.000003e+67, +INFINITY), +INFINITY); /* 14. Exponent = +Inf and |base| > 1: Return +Inf */
|
---|
2749 | CHECK_DBL( RT_NOCRT(pow)( -996.6567e+109, +INFINITY), +INFINITY); /* 14. Exponent = +Inf and |base| > 1: Return +Inf */
|
---|
2750 | CHECK_DBL( RT_NOCRT(pow)( -1.23, 1.1), RTStrNanDouble(NULL, false)); /* 1. Finit base < 0 and finit non-interger exponent: -> domain error (#IE) + NaN. */
|
---|
2751 | CHECK_DBL( RT_NOCRT(pow)( -2.0, -42.353), RTStrNanDouble(NULL, false)); /* 1. Finit base < 0 and finit non-interger exponent: -> domain error (#IE) + NaN. */
|
---|
2752 | CHECK_DBL( RT_NOCRT(pow)( -2.0, -0.0), +1.0); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2753 | CHECK_DBL( RT_NOCRT(pow)( -2.0, +0.0), +1.0); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2754 | CHECK_DBL( RT_NOCRT(pow)( -INFINITY, -0.0), +1.0); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2755 | CHECK_DBL( RT_NOCRT(pow)( -INFINITY, +0.0), +1.0); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2756 | CHECK_DBL( RT_NOCRT(pow)( +INFINITY, -0.0), +1.0); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2757 | CHECK_DBL( RT_NOCRT(pow)( +INFINITY, +0.0), +1.0); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2758 | CHECK_DBL( RT_NOCRT(pow)( RTStrNanDouble("s", false), -0.0), +1.0); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2759 | CHECK_DBL( RT_NOCRT(pow)( RTStrNanDouble(NULL, true), +0.0), +1.0); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2760 | CHECK_DBL( RT_NOCRT(pow)( -0.0, -19.0), -INFINITY); /* 4a. base == +/-0.0 and exp < 0 and exp is odd integer: Return +/-Inf, raise div/0. */
|
---|
2761 | CHECK_DBL( RT_NOCRT(pow)( +0.0, -7.0), +INFINITY); /* 4a. base == +/-0.0 and exp < 0 and exp is odd integer: Return +/-Inf, raise div/0. */
|
---|
2762 | CHECK_DBL( RT_NOCRT(pow)( -0.0, -8.0), +INFINITY); /* 4b. base == +/-0.0 and exp < 0 and exp is not odd int: Return +Inf, raise div/0. */
|
---|
2763 | CHECK_DBL( RT_NOCRT(pow)( +0.0, -8.0), +INFINITY); /* 4b. base == +/-0.0 and exp < 0 and exp is not odd int: Return +Inf, raise div/0. */
|
---|
2764 | CHECK_DBL( RT_NOCRT(pow)( -0.0, -9.1), +INFINITY); /* 4b. base == +/-0.0 and exp < 0 and exp is not odd int: Return +Inf, raise div/0. */
|
---|
2765 | CHECK_DBL( RT_NOCRT(pow)( +0.0, -9.1), +INFINITY); /* 4b. base == +/-0.0 and exp < 0 and exp is not odd int: Return +Inf, raise div/0. */
|
---|
2766 | CHECK_DBL( RT_NOCRT(pow)( -0.0, +49.0), -0.0); /* 8. base == +/-0.0 and exp > 0 and exp is odd integer: Return +/-0.0 */
|
---|
2767 | CHECK_DBL( RT_NOCRT(pow)( -0.0, +999999999.0), -0.0); /* 8. base == +/-0.0 and exp > 0 and exp is odd integer: Return +/-0.0 */
|
---|
2768 | CHECK_DBL( RT_NOCRT(pow)( +0.0, +88888881.0), +0.0); /* 8. base == +/-0.0 and exp > 0 and exp is odd integer: Return +/-0.0 */
|
---|
2769 | CHECK_DBL( RT_NOCRT(pow)( +0.0, +3.0), +0.0); /* 8. base == +/-0.0 and exp > 0 and exp is odd integer: Return +/-0.0 */
|
---|
2770 | CHECK_DBL( RT_NOCRT(pow)( +0.0, +4.0), +0.0); /* 9. base == +/-0.0 and exp > 0 and exp is not odd int: Return +0 */
|
---|
2771 | CHECK_DBL( RT_NOCRT(pow)( -0.0, +4.0), +0.0); /* 9. base == +/-0.0 and exp > 0 and exp is not odd int: Return +0 */
|
---|
2772 | CHECK_DBL( RT_NOCRT(pow)( +0.0, +3.1), +0.0); /* 9. base == +/-0.0 and exp > 0 and exp is not odd int: Return +0 */
|
---|
2773 | CHECK_DBL( RT_NOCRT(pow)( -0.0, +3.1), +0.0); /* 9. base == +/-0.0 and exp > 0 and exp is not odd int: Return +0 */
|
---|
2774 | CHECK_DBL( RT_NOCRT(pow)( +0.0, +999999999.9), +0.0); /* 9. base == +/-0.0 and exp > 0 and exp is not odd int: Return +0 */
|
---|
2775 | CHECK_DBL( RT_NOCRT(pow)( -0.0, +999999999.9), +0.0); /* 9. base == +/-0.0 and exp > 0 and exp is not odd int: Return +0 */
|
---|
2776 | CHECK_DBL( RT_NOCRT(pow)( -INFINITY, -999999999.0), -0.0); /* 15. base == -Inf and exp < 0 and exp is odd integer: Return -0 */
|
---|
2777 | CHECK_DBL( RT_NOCRT(pow)( -INFINITY, -3.0), -0.0); /* 15. base == -Inf and exp < 0 and exp is odd integer: Return -0 */
|
---|
2778 | CHECK_DBL( RT_NOCRT(pow)( -INFINITY, -3.1), +0.0); /* 16. base == -Inf and exp < 0 and exp is not odd int: Return +0 */
|
---|
2779 | CHECK_DBL( RT_NOCRT(pow)( -INFINITY, -4.0), +0.0); /* 16. base == -Inf and exp < 0 and exp is not odd int: Return +0 */
|
---|
2780 | CHECK_DBL( RT_NOCRT(pow)( -INFINITY, +3.0), -INFINITY); /* 17. base == -Inf and exp > 0 and exp is odd integer: Return -Inf */
|
---|
2781 | CHECK_DBL( RT_NOCRT(pow)( -INFINITY, +7777777777.0), -INFINITY); /* 17. base == -Inf and exp > 0 and exp is odd integer: Return -Inf */
|
---|
2782 | CHECK_DBL( RT_NOCRT(pow)( -INFINITY, +7777777777.7), +INFINITY); /* 18. base == -Inf and exp > 0 and exp is not odd int: Return +Inf */
|
---|
2783 | CHECK_DBL( RT_NOCRT(pow)( -INFINITY, +4.0), +INFINITY); /* 18. base == -Inf and exp > 0 and exp is not odd int: Return +Inf */
|
---|
2784 | CHECK_DBL( RT_NOCRT(pow)( +INFINITY, -4.0), +0.0); /* 19. base == +Inf and exp < 0: Return +0 */
|
---|
2785 | CHECK_DBL( RT_NOCRT(pow)( +INFINITY, -0.9), +0.0); /* 19. base == +Inf and exp < 0: Return +0 */
|
---|
2786 | CHECK_DBL( RT_NOCRT(pow)( +INFINITY, -4.4), +0.0); /* 19. base == +Inf and exp < 0: Return +0 */
|
---|
2787 | CHECK_DBL( RT_NOCRT(pow)( +INFINITY, +4.0), +INFINITY); /* 20. base == +Inf and exp > 0: Return +Inf */
|
---|
2788 | CHECK_DBL( RT_NOCRT(pow)( +INFINITY, +4.4), +INFINITY); /* 20. base == +Inf and exp > 0: Return +Inf */
|
---|
2789 | CHECK_DBL( RT_NOCRT(pow)( +INFINITY, +0.3), +INFINITY); /* 20. base == +Inf and exp > 0: Return +Inf */
|
---|
2790 |
|
---|
2791 | /* Integer exponents: */
|
---|
2792 | //lvbe /mnt/e/misc/float/pow +1.0 +1.0 +2.0 +1.0 +2.0 +2.0 +2.0 +15.0 +2.0 +42.0 -2.5 +3.0 -2.5 +4.0 -2.5 +16.0 +2.0 -1.0 +2.0 -2.0 +2.0 -3.0 -42.5 -7.0 | clip
|
---|
2793 | CHECK_DBL( RT_NOCRT(pow)( +1.0, +1.0), +1);
|
---|
2794 | CHECK_DBL( RT_NOCRT(pow)( +2.0, +1.0), +2);
|
---|
2795 | CHECK_DBL( RT_NOCRT(pow)( +2.0, +2.0), +4);
|
---|
2796 | CHECK_DBL( RT_NOCRT(pow)( +2.0, +15.0), +32768);
|
---|
2797 | CHECK_DBL( RT_NOCRT(pow)( +2.0, +42.0), +4398046511104);
|
---|
2798 | CHECK_DBL( RT_NOCRT(pow)( -2.5, +3.0), -15.625);
|
---|
2799 | CHECK_DBL( RT_NOCRT(pow)( -2.5, +4.0), +39.0625);
|
---|
2800 | CHECK_DBL( RT_NOCRT(pow)( -2.5, +16.0), +2328306.4365386962891);
|
---|
2801 | CHECK_DBL( RT_NOCRT(pow)( +2.0, -1.0), +0.5);
|
---|
2802 | CHECK_DBL( RT_NOCRT(pow)( +2.0, -2.0), +0.25);
|
---|
2803 | CHECK_DBL( RT_NOCRT(pow)( +2.0, -3.0), +0.125);
|
---|
2804 | /* Fractional exponents: */
|
---|
2805 | //lvbe /mnt/e/misc/float/pow +2.0 +1.0001 +2.0 +1.5 +2.0 -1.5 +2.0 -1.1 +2.0 -0.98 +2.5 +0.39 +42.424242 +22.34356458 +88888888.9999999e+10 +2.7182818284590452354 +9999387.349569 -2.7182818284590452354| clip
|
---|
2806 | CHECK_DBL( RT_NOCRT(pow)( +2.0, +1.0001), +2.0001386342407529995);
|
---|
2807 | CHECK_DBL( RT_NOCRT(pow)( +2.0, +1.5), +2.8284271247461902909);
|
---|
2808 | CHECK_DBL( RT_NOCRT(pow)( +2.0, -1.5), +0.35355339059327378637);
|
---|
2809 | CHECK_DBL( RT_NOCRT(pow)( +2.0, -1.1), +0.46651649576840370504);
|
---|
2810 | CHECK_DBL( RT_NOCRT(pow)( +2.0, -0.98), +0.50697973989501454728);
|
---|
2811 | CHECK_DBL( RT_NOCRT(pow)( +2.5, +0.39), +1.4295409595509598333);
|
---|
2812 | CHECK_DBL_RANGE(RT_NOCRT(pow)( +42.424242, +22.34356458), +2.3264866447369911544e+36, 0.00000000000001e+36);
|
---|
2813 | CHECK_DBL_RANGE(RT_NOCRT(pow)( +88888888.9999999e+10, +2.7182818284590452354), +6.1663183371503584444e+48, 0.00000000000001e+48);
|
---|
2814 | CHECK_DBL_RANGE(RT_NOCRT(pow)( +9999387.349569, -2.7182818284590452354), +9.3777689533441608684e-20, 0.00000000000001e-20);
|
---|
2815 |
|
---|
2816 | /*
|
---|
2817 | * powf
|
---|
2818 | */
|
---|
2819 | CHECK_FLT( RT_NOCRT(powf)( +1.0f, +1.0f), +1.0f);
|
---|
2820 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, +1.0f), +2.0f);
|
---|
2821 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, +2.0f), +4.0f);
|
---|
2822 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, +43.0f), +8796093022208.0f);
|
---|
2823 |
|
---|
2824 | /* Integer exponents: */
|
---|
2825 | //lvbe /mnt/e/misc/float/pow -f +1.0 +1.0 +2.0 +1.0 +2.0 +2.0 +2.0 +15.0 +2.0 +42.0 -2.5 +3.0 -2.5 +4.0 -2.5 +16.0 +2.0 -1.0 +2.0 -2.0 +2.0 -3.0 -42.5 -7.0 | clip
|
---|
2826 | CHECK_FLT( RT_NOCRT(powf)( +1.0f, +1.0f), +1.0f);
|
---|
2827 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, +1.0f), +2.0f);
|
---|
2828 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, +2.0f), +4.0f);
|
---|
2829 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, +15.0f), +32768.0f);
|
---|
2830 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, +42.0f), +4398046511104.0f);
|
---|
2831 | CHECK_FLT( RT_NOCRT(powf)( -2.5f, +3.0f), -15.625f);
|
---|
2832 | CHECK_FLT( RT_NOCRT(powf)( -2.5f, +4.0f), +39.0625f);
|
---|
2833 | CHECK_FLT( RT_NOCRT(powf)( -2.5f, +16.0f), +2328306.5f);
|
---|
2834 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, -1.0f), +0.5f);
|
---|
2835 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, -2.0f), +0.25f);
|
---|
2836 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, -3.0f), +0.125f);
|
---|
2837 | CHECK_FLT( RT_NOCRT(powf)( -42.5f, -7.0f), -3.99279958054888e-12f);
|
---|
2838 | /* Fractional exponents: */
|
---|
2839 | //lvbe /mnt/e/misc/float/pow -f +2.0 +1.0001 +2.0 +1.5 +2.0 -1.5 +2.0 -1.1 +2.0 -0.98 +2.5 +0.39 +42.424242 +22.34356458 +88888888.9999999e+6 +2.7182818284590452354 +9999387.349569 -2.7182818284590452354| clip
|
---|
2840 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, +1.0001f), +2.00013875961304f);
|
---|
2841 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, +1.5f), +2.82842707633972f);
|
---|
2842 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, -1.5f), +0.353553384542465f);
|
---|
2843 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, -1.1f), +0.466516494750977f);
|
---|
2844 | CHECK_FLT( RT_NOCRT(powf)( +2.0f, -0.98f), +0.506979703903198f);
|
---|
2845 | CHECK_FLT( RT_NOCRT(powf)( +2.5f, +0.39f), +1.42954099178314f);
|
---|
2846 | CHECK_FLT( RT_NOCRT(powf)( +42.424242f, +22.34356458f), +2.32648793070284e+36f);
|
---|
2847 | CHECK_FLT( RT_NOCRT(powf)( +88888888.9999999e+6f, +2.7182818284590452354f), +8.25842928313806e+37f);
|
---|
2848 | CHECK_FLT( RT_NOCRT(powf)( +9999387.349569f, -2.7182818284590452354f), +9.37778214743062e-20f);
|
---|
2849 |
|
---|
2850 | /* special values: */
|
---|
2851 | CHECK_FLT( RT_NOCRT(powf)( +1.0f, 43.0f), +1.0f); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2852 | CHECK_FLT( RT_NOCRT(powf)( +1.0f, +0.0f), +1.0f); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2853 | CHECK_FLT( RT_NOCRT(powf)( +1.0f, -0.0f), +1.0f); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2854 | CHECK_FLT( RT_NOCRT(powf)( +1.0f, -34.5534f), +1.0f); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2855 | CHECK_FLT( RT_NOCRT(powf)( +1.0f, +1.0e+37f), +1.0f); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2856 | CHECK_FLT( RT_NOCRT(powf)( +1.0f, -1.0e+37f), +1.0f); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2857 | CHECK_FLT( RT_NOCRT(powf)( +1.0f, +(float)INFINITY), +1.0f); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2858 | CHECK_FLT( RT_NOCRT(powf)( +1.0f, -(float)INFINITY), +1.0f); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2859 | CHECK_FLT( RT_NOCRT(powf)( +1.0f, RTStrNanFloat(NULL, true)), +1.0f); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2860 | CHECK_FLT( RT_NOCRT(powf)( +1.0f, RTStrNanFloat("s", false)), +1.0f); /* 6. base=1 exp=wathever -> +1.0 */
|
---|
2861 | CHECK_FLT( RT_NOCRT(powf)( -1.0f, +(float)INFINITY), +1.0f); /* 10. Exponent = +/-Inf and base = -1: Return 1.0 */
|
---|
2862 | CHECK_FLT( RT_NOCRT(powf)( +0.9f, -(float)INFINITY), +(float)INFINITY); /* 11. Exponent = -Inf and |base| < 1: Return +Inf */
|
---|
2863 | CHECK_FLT( RT_NOCRT(powf)( +0.3490f, -(float)INFINITY), +(float)INFINITY); /* 11. Exponent = -Inf and |base| < 1: Return +Inf */
|
---|
2864 | CHECK_FLT( RT_NOCRT(powf)( -0.9f, -(float)INFINITY), +(float)INFINITY); /* 11. Exponent = -Inf and |base| < 1: Return +Inf */
|
---|
2865 | CHECK_FLT( RT_NOCRT(powf)( -0.165634f, -(float)INFINITY), +(float)INFINITY); /* 11. Exponent = -Inf and |base| < 1: Return +Inf */
|
---|
2866 | CHECK_FLT( RT_NOCRT(powf)( -1.000001f, -(float)INFINITY), +0.0f); /* 12. Exponent = -Inf and |base| > 1: Return +0 */
|
---|
2867 | CHECK_FLT( RT_NOCRT(powf)( +1.000001f, -(float)INFINITY), +0.0f); /* 12. Exponent = -Inf and |base| > 1: Return +0 */
|
---|
2868 | CHECK_FLT( RT_NOCRT(powf)( +42.1f, -(float)INFINITY), +0.0f); /* 12. Exponent = -Inf and |base| > 1: Return +0 */
|
---|
2869 | CHECK_FLT( RT_NOCRT(powf)( -42.1e+34f, -(float)INFINITY), +0.0f); /* 12. Exponent = -Inf and |base| > 1: Return +0 */
|
---|
2870 | CHECK_FLT( RT_NOCRT(powf)( +42.1e+32f, -(float)INFINITY), +0.0f); /* 12. Exponent = -Inf and |base| > 1: Return +0 */
|
---|
2871 | CHECK_FLT( RT_NOCRT(powf)( +0.8f, +(float)INFINITY), +0.0f); /* 13. Exponent = +Inf and |base| < 1: Return +0 */
|
---|
2872 | CHECK_FLT( RT_NOCRT(powf)( -0.8f, +(float)INFINITY), +0.0f); /* 13. Exponent = +Inf and |base| < 1: Return +0 */
|
---|
2873 | CHECK_FLT( RT_NOCRT(powf)( +1.000003f, +(float)INFINITY), +(float)INFINITY); /* 14. Exponent = +Inf and |base| > 1: Return +Inf */
|
---|
2874 | CHECK_FLT( RT_NOCRT(powf)( -1.000003f, +(float)INFINITY), +(float)INFINITY); /* 14. Exponent = +Inf and |base| > 1: Return +Inf */
|
---|
2875 | CHECK_FLT( RT_NOCRT(powf)( +42.000003e+33f, +(float)INFINITY), +(float)INFINITY); /* 14. Exponent = +Inf and |base| > 1: Return +Inf */
|
---|
2876 | CHECK_FLT( RT_NOCRT(powf)( -996.6567e+30f, +(float)INFINITY), +(float)INFINITY); /* 14. Exponent = +Inf and |base| > 1: Return +Inf */
|
---|
2877 | CHECK_FLT( RT_NOCRT(powf)( -1.23f, 1.1f), RTStrNanFloat(NULL, false)); /* 1. Finit base < 0 and finit non-interger exponent: -> domain error (#IE) + NaN. */
|
---|
2878 | CHECK_FLT( RT_NOCRT(powf)( -2.0f, -42.32f), RTStrNanFloat(NULL, false)); /* 1. Finit base < 0 and finit non-interger exponent: -> domain error (#IE) + NaN. */
|
---|
2879 | CHECK_FLT( RT_NOCRT(powf)( -2.0f, -0.0f), +1.0f); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2880 | CHECK_FLT( RT_NOCRT(powf)( -2.0f, +0.0f), +1.0f); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2881 | CHECK_FLT( RT_NOCRT(powf)( -(float)INFINITY, -0.0f), +1.0f); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2882 | CHECK_FLT( RT_NOCRT(powf)( -(float)INFINITY, +0.0f), +1.0f); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2883 | CHECK_FLT( RT_NOCRT(powf)( +(float)INFINITY, -0.0f), +1.0f); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2884 | CHECK_FLT( RT_NOCRT(powf)( +(float)INFINITY, +0.0f), +1.0f); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2885 | CHECK_FLT( RT_NOCRT(powf)( RTStrNanFloat("s", false), -0.0f), +1.0f); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2886 | CHECK_FLT( RT_NOCRT(powf)( RTStrNanFloat(NULL, true), +0.0f), +1.0f); /* 7. Exponent = +/-0.0, any base value including NaN: return +1.0 */
|
---|
2887 | CHECK_FLT( RT_NOCRT(powf)( -0.0f, -19.0f), -(float)INFINITY); /* 4a. base == +/-0.0 and exp < 0 and exp is odd integer: Return +/-Inf, raise div/0. */
|
---|
2888 | CHECK_FLT( RT_NOCRT(powf)( +0.0f, -7.0f), +(float)INFINITY); /* 4a. base == +/-0.0 and exp < 0 and exp is odd integer: Return +/-Inf, raise div/0. */
|
---|
2889 | CHECK_FLT( RT_NOCRT(powf)( -0.0f, -8.0f), +(float)INFINITY); /* 4b. base == +/-0.0 and exp < 0 and exp is not odd int: Return +Inf, raise div/0. */
|
---|
2890 | CHECK_FLT( RT_NOCRT(powf)( +0.0f, -8.0f), +(float)INFINITY); /* 4b. base == +/-0.0 and exp < 0 and exp is not odd int: Return +Inf, raise div/0. */
|
---|
2891 | CHECK_FLT( RT_NOCRT(powf)( -0.0f, -9.1f), +(float)INFINITY); /* 4b. base == +/-0.0 and exp < 0 and exp is not odd int: Return +Inf, raise div/0. */
|
---|
2892 | CHECK_FLT( RT_NOCRT(powf)( +0.0f, -9.1f), +(float)INFINITY); /* 4b. base == +/-0.0 and exp < 0 and exp is not odd int: Return +Inf, raise div/0. */
|
---|
2893 | CHECK_FLT( RT_NOCRT(powf)( -0.0f, +49.0f), -0.0f); /* 8. base == +/-0.0 and exp > 0 and exp is odd integer: Return +/-0.0 */
|
---|
2894 | CHECK_FLT( RT_NOCRT(powf)( -0.0f, +999999.0f), -0.0f); /* 8. base == +/-0.0 and exp > 0 and exp is odd integer: Return +/-0.0 */
|
---|
2895 | CHECK_FLT( RT_NOCRT(powf)( +0.0f, +88881.0f), +0.0f); /* 8. base == +/-0.0 and exp > 0 and exp is odd integer: Return +/-0.0 */
|
---|
2896 | CHECK_FLT( RT_NOCRT(powf)( +0.0f, +3.0f), +0.0f); /* 8. base == +/-0.0 and exp > 0 and exp is odd integer: Return +/-0.0 */
|
---|
2897 | CHECK_FLT( RT_NOCRT(powf)( +0.0f, +4.0f), +0.0f); /* 9. base == +/-0.0 and exp > 0 and exp is not odd int: Return +0 */
|
---|
2898 | CHECK_FLT( RT_NOCRT(powf)( -0.0f, +4.0f), +0.0f); /* 9. base == +/-0.0 and exp > 0 and exp is not odd int: Return +0 */
|
---|
2899 | CHECK_FLT( RT_NOCRT(powf)( +0.0f, +3.1f), +0.0f); /* 9. base == +/-0.0 and exp > 0 and exp is not odd int: Return +0 */
|
---|
2900 | CHECK_FLT( RT_NOCRT(powf)( -0.0f, +3.1f), +0.0f); /* 9. base == +/-0.0 and exp > 0 and exp is not odd int: Return +0 */
|
---|
2901 | CHECK_FLT( RT_NOCRT(powf)( +0.0f, +99999.9f), +0.0f); /* 9. base == +/-0.0 and exp > 0 and exp is not odd int: Return +0 */
|
---|
2902 | CHECK_FLT( RT_NOCRT(powf)( -0.0f, +99999.9f), +0.0f); /* 9. base == +/-0.0 and exp > 0 and exp is not odd int: Return +0 */
|
---|
2903 | CHECK_FLT( RT_NOCRT(powf)( -(float)INFINITY, -99999.0f), -0.0f); /* 15. base == -Inf and exp < 0 and exp is odd integer: Return -0 */
|
---|
2904 | CHECK_FLT( RT_NOCRT(powf)( -(float)INFINITY, -3.0f), -0.0f); /* 15. base == -Inf and exp < 0 and exp is odd integer: Return -0 */
|
---|
2905 | CHECK_FLT( RT_NOCRT(powf)( -(float)INFINITY, -3.1f), +0.0f); /* 16. base == -Inf and exp < 0 and exp is not odd int: Return +0 */
|
---|
2906 | CHECK_FLT( RT_NOCRT(powf)( -(float)INFINITY, -4.0f), +0.0f); /* 16. base == -Inf and exp < 0 and exp is not odd int: Return +0 */
|
---|
2907 | CHECK_FLT( RT_NOCRT(powf)( -(float)INFINITY, +3.0f), -(float)INFINITY); /* 17. base == -Inf and exp > 0 and exp is odd integer: Return -Inf */
|
---|
2908 | CHECK_FLT( RT_NOCRT(powf)( -(float)INFINITY, +777777.0f), -(float)INFINITY); /* 17. base == -Inf and exp > 0 and exp is odd integer: Return -Inf */
|
---|
2909 | CHECK_FLT( RT_NOCRT(powf)( -(float)INFINITY, +77777.7f), +(float)INFINITY); /* 18. base == -Inf and exp > 0 and exp is not odd int: Return +Inf */
|
---|
2910 | CHECK_FLT( RT_NOCRT(powf)( -(float)INFINITY, +4.0f), +(float)INFINITY); /* 18. base == -Inf and exp > 0 and exp is not odd int: Return +Inf */
|
---|
2911 | CHECK_FLT( RT_NOCRT(powf)( +(float)INFINITY, -4.0f), +0.0f); /* 19. base == +Inf and exp < 0: Return +0 */
|
---|
2912 | CHECK_FLT( RT_NOCRT(powf)( +(float)INFINITY, -0.9f), +0.0f); /* 19. base == +Inf and exp < 0: Return +0 */
|
---|
2913 | CHECK_FLT( RT_NOCRT(powf)( +(float)INFINITY, -4.4f), +0.0f); /* 19. base == +Inf and exp < 0: Return +0 */
|
---|
2914 | CHECK_FLT( RT_NOCRT(powf)( +(float)INFINITY, +4.0f), +(float)INFINITY); /* 20. base == +Inf and exp > 0: Return +Inf */
|
---|
2915 | CHECK_FLT( RT_NOCRT(powf)( +(float)INFINITY, +4.4f), +(float)INFINITY); /* 20. base == +Inf and exp > 0: Return +Inf */
|
---|
2916 | CHECK_FLT( RT_NOCRT(powf)( +(float)INFINITY, +0.3f), +(float)INFINITY); /* 20. base == +Inf and exp > 0: Return +Inf */
|
---|
2917 |
|
---|
2918 | }
|
---|
2919 |
|
---|
2920 | void testFma()
|
---|
2921 | {
|
---|
2922 | RTTestSub(g_hTest, "fma[f]");
|
---|
2923 |
|
---|
2924 | CHECK_DBL(RT_NOCRT(fma)(1.0, 1.0, 1.0), 2.0);
|
---|
2925 | CHECK_DBL(RT_NOCRT(fma)(4.0, 2.0, 1.0), 9.0);
|
---|
2926 | CHECK_DBL(RT_NOCRT(fma)(4.0, 2.0, -1.0), 7.0);
|
---|
2927 | CHECK_DBL_SAME(fma, (0.0, 0.0, 0.0));
|
---|
2928 | CHECK_DBL_SAME(fma, (999999.0, 33334.0, 29345.0));
|
---|
2929 | CHECK_DBL_SAME(fma, (39560.32334, 9605.5546, -59079.345069));
|
---|
2930 | CHECK_DBL_SAME(fma, (39560.32334, -59079.345069, 9605.5546));
|
---|
2931 | CHECK_DBL_SAME(fma, (-59079.345069, 39560.32334, 9605.5546));
|
---|
2932 | CHECK_DBL_SAME(fma, (+INFINITY, +INFINITY, -INFINITY));
|
---|
2933 | CHECK_DBL_SAME(fma, (4.0, +INFINITY, 2.0));
|
---|
2934 | CHECK_DBL_SAME(fma, (4.0, 4.0, +INFINITY));
|
---|
2935 | CHECK_DBL_SAME(fma, (-INFINITY, 4.0, 4.0));
|
---|
2936 | CHECK_DBL_SAME(fma, (2.34960584706e100, 7.6050698459e-13, 9.99996777e77));
|
---|
2937 |
|
---|
2938 | CHECK_FLT(RT_NOCRT(fmaf)(1.0f, 1.0f, 1.0), 2.0);
|
---|
2939 | CHECK_FLT(RT_NOCRT(fmaf)(4.0f, 2.0f, 1.0), 9.0);
|
---|
2940 | CHECK_FLT(RT_NOCRT(fmaf)(4.0f, 2.0f, -1.0), 7.0);
|
---|
2941 | CHECK_FLT_SAME(fmaf, (0.0f, 0.0f, 0.0f));
|
---|
2942 | CHECK_FLT_SAME(fmaf, (999999.0f, 33334.0f, 29345.0f));
|
---|
2943 | CHECK_FLT_SAME(fmaf, (39560.32334f, 9605.5546f, -59079.345069f));
|
---|
2944 | CHECK_FLT_SAME(fmaf, (39560.32334f, -59079.345069f, 9605.5546f));
|
---|
2945 | CHECK_FLT_SAME(fmaf, (-59079.345069f, 39560.32334f, 9605.5546f));
|
---|
2946 | CHECK_FLT_SAME(fmaf, (+INFINITY, +INFINITY, -INFINITY));
|
---|
2947 | CHECK_FLT_SAME(fmaf, (4.0f, +INFINITY, 2.0f));
|
---|
2948 | CHECK_FLT_SAME(fmaf, (4.0f, 4.0f, +INFINITY));
|
---|
2949 | CHECK_FLT_SAME(fmaf, (-INFINITY, 4.0f, 4.0f));
|
---|
2950 | CHECK_FLT_SAME(fmaf, (2.34960584706e22f, 7.6050698459e-13f, 9.99996777e27f));
|
---|
2951 | }
|
---|
2952 |
|
---|
2953 |
|
---|
2954 | void testRemainder()
|
---|
2955 | {
|
---|
2956 | RTTestSub(g_hTest, "remainder[f]");
|
---|
2957 |
|
---|
2958 | /* The UCRT and x87 FPU generally disagree on the sign of the NaN, so don't be too picky here for now. */
|
---|
2959 |
|
---|
2960 | CHECK_DBL( RT_NOCRT(remainder)( 1.0, 1.0), +0.0);
|
---|
2961 | CHECK_DBL( RT_NOCRT(remainder)( 1.5, 1.0), -0.5);
|
---|
2962 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( 1.0, 1.0));
|
---|
2963 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( 1.5, 1.0));
|
---|
2964 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( +0.0, +0.0));
|
---|
2965 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( +0.0, -0.0));
|
---|
2966 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( -0.0, -0.0));
|
---|
2967 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( -0.0, +0.0));
|
---|
2968 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( 999999.0, 33334.0));
|
---|
2969 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( -999999.0, 33334.0));
|
---|
2970 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( -999999.0, -33334.0));
|
---|
2971 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( 999999.0, -33334.0));
|
---|
2972 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( 39560.32334, 9605.5546));
|
---|
2973 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( 39560.32334, -59079.345069));
|
---|
2974 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( +INFINITY, +INFINITY));
|
---|
2975 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( 2.4, +INFINITY));
|
---|
2976 | CHECK_DBL_SAME_RELAXED_NAN(remainder,( +INFINITY, 2.4));
|
---|
2977 | CHECK_DBL_SAME_RELAXED_NAN(remainder,(2.34960584706e100, 7.6050698459e+13));
|
---|
2978 | CHECK_DBL_SAME_RELAXED_NAN(remainder,(2.34960584706e300, -7.6050698459e-13));
|
---|
2979 | CHECK_DBL_SAME_RELAXED_NAN(remainder,(2.34960584706e300, RTStrNanDouble(NULL, true)));
|
---|
2980 | CHECK_DBL_SAME_RELAXED_NAN(remainder,(RTStrNanDouble(NULL, true), 2.0));
|
---|
2981 | CHECK_DBL_SAME_RELAXED_NAN(remainder,(RTStrNanDouble(NULL, true), RTStrNanDouble("s", false)));
|
---|
2982 |
|
---|
2983 | CHECK_FLT( RT_NOCRT(remainderf)( 1.0f, 1.0f), +0.0f);
|
---|
2984 | CHECK_FLT( RT_NOCRT(remainderf)( 1.5f, 1.0f), -0.5f);
|
---|
2985 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 1.0f, 1.0f));
|
---|
2986 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 1.5f, 1.0f));
|
---|
2987 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( +0.0f, +0.0f));
|
---|
2988 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( +0.0f, -0.0f));
|
---|
2989 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( -0.0f, -0.0f));
|
---|
2990 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( -0.0f, +0.0f));
|
---|
2991 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 999999.0f, 33334.0f));
|
---|
2992 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( -999999.0f, 33334.0f));
|
---|
2993 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( -999999.0f, -33334.0f));
|
---|
2994 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 999999.0f, -33334.0f));
|
---|
2995 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 39560.32334f, 9605.5546f));
|
---|
2996 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 39560.32334f, -59079.345069f));
|
---|
2997 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( +INFINITY, +INFINITY));
|
---|
2998 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 2.4f, +INFINITY));
|
---|
2999 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,( +INFINITY, 2.4f));
|
---|
3000 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,(-2.34960584706e+35f, 7.6050698459e-23f));
|
---|
3001 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,(2.34960584706e+35f, 7.6050698459e-13f));
|
---|
3002 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,(2.34960584706e+30f, RTStrNanFloat(NULL, true)));
|
---|
3003 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,(RTStrNanFloat(NULL, true), 2.0f));
|
---|
3004 | CHECK_FLT_SAME_RELAXED_NAN(remainderf,(RTStrNanFloat(NULL, true), RTStrNanFloat("s", false)));
|
---|
3005 | }
|
---|
3006 |
|
---|
3007 |
|
---|
3008 | void testLog()
|
---|
3009 | {
|
---|
3010 | RTTestSub(g_hTest, "log[f]");
|
---|
3011 |
|
---|
3012 | CHECK_DBL(RT_NOCRT(log)( 1.0), +0.0);
|
---|
3013 | CHECK_DBL(RT_NOCRT(log)(2.7182818284590452354), +1.0);
|
---|
3014 | CHECK_DBL(RT_NOCRT(log)(2.0), 0.69314718055994530942);
|
---|
3015 | CHECK_DBL_SAME(log,( 1.0));
|
---|
3016 | CHECK_DBL_SAME(log,( 1.5));
|
---|
3017 | CHECK_DBL_SAME(log,( +0.0));
|
---|
3018 | CHECK_DBL_SAME(log,( +0.0));
|
---|
3019 | CHECK_DBL_SAME(log,( -0.0));
|
---|
3020 | CHECK_DBL_SAME(log,( -0.0));
|
---|
3021 | CHECK_DBL_SAME(log,( 999999.0));
|
---|
3022 | CHECK_DBL_SAME(log,( -999999.0));
|
---|
3023 | CHECK_DBL_SAME(log,( -999999.0));
|
---|
3024 | CHECK_DBL_SAME(log,( 999999.0));
|
---|
3025 | CHECK_DBL_SAME(log,( 39560.32334));
|
---|
3026 | CHECK_DBL_SAME(log,( 39560.32334));
|
---|
3027 | CHECK_DBL_SAME(log,( +INFINITY));
|
---|
3028 | CHECK_DBL_SAME(log,( -INFINITY));
|
---|
3029 | CHECK_DBL_SAME(log,( +DBL_MAX));
|
---|
3030 | CHECK_DBL_SAME(log,( -DBL_MAX));
|
---|
3031 | CHECK_DBL_SAME(log,(2.34960584706e100));
|
---|
3032 | CHECK_DBL_SAME(log,(2.34960584706e300));
|
---|
3033 | CHECK_DBL_SAME(log,(2.34960584706e300));
|
---|
3034 | CHECK_DBL_SAME(log,(RTStrNanDouble(NULL, true)));
|
---|
3035 | CHECK_DBL_SAME(log,(RTStrNanDouble("s", true)));
|
---|
3036 | CHECK_DBL_SAME(log,(RTStrNanDouble("s", false)));
|
---|
3037 |
|
---|
3038 | CHECK_FLT(RT_NOCRT(logf)( 1.0f), +0.0f);
|
---|
3039 | CHECK_FLT(RT_NOCRT(logf)((float)2.7182818284590452354), +0.99999995f); /* floating point is fun */
|
---|
3040 | CHECK_FLT(RT_NOCRT(logf)(2.0f), (float)0.69314718055994530942);
|
---|
3041 | CHECK_FLT_SAME(logf,((float)2.7182818284590452354));
|
---|
3042 | CHECK_FLT_SAME(logf,( 1.0f));
|
---|
3043 | CHECK_FLT_SAME(logf,( 1.5f));
|
---|
3044 | CHECK_FLT_SAME(logf,( +0.0f));
|
---|
3045 | CHECK_FLT_SAME(logf,( +0.0f));
|
---|
3046 | CHECK_FLT_SAME(logf,( -0.0f));
|
---|
3047 | CHECK_FLT_SAME(logf,( -0.0f));
|
---|
3048 | CHECK_FLT_SAME(logf,( 999999.0f));
|
---|
3049 | CHECK_FLT_SAME(logf,( -999999.0f));
|
---|
3050 | CHECK_FLT_SAME(logf,( -999999.0f));
|
---|
3051 | CHECK_FLT_SAME(logf,( 999999.0f));
|
---|
3052 | CHECK_FLT_SAME(logf,( 39560.32334f));
|
---|
3053 | CHECK_FLT_SAME(logf,( 39560.32334f));
|
---|
3054 | CHECK_FLT_SAME(logf,( +INFINITY));
|
---|
3055 | CHECK_FLT_SAME(logf,( -INFINITY));
|
---|
3056 | CHECK_FLT_SAME(logf,( +FLT_MAX));
|
---|
3057 | CHECK_FLT_SAME(logf,( -FLT_MAX));
|
---|
3058 | CHECK_FLT_SAME(logf,(2.34960584706e+10f));
|
---|
3059 | CHECK_FLT_SAME(logf,(2.34960584706e+30f));
|
---|
3060 | CHECK_FLT_SAME(logf,(2.34960584706e+30f));
|
---|
3061 | CHECK_FLT_SAME(logf,(RTStrNanFloat(NULL, true)));
|
---|
3062 | CHECK_FLT_SAME(logf,(RTStrNanFloat("s", true)));
|
---|
3063 | CHECK_FLT_SAME(logf,(RTStrNanFloat("s", false)));
|
---|
3064 | }
|
---|
3065 |
|
---|
3066 |
|
---|
3067 | void testLog2()
|
---|
3068 | {
|
---|
3069 | RTTestSub(g_hTest, "log2[f]");
|
---|
3070 |
|
---|
3071 | CHECK_DBL( RT_NOCRT(log2)(RTStrNanDouble(NULL, true)), RTStrNanDouble(NULL, true));
|
---|
3072 | CHECK_DBL( RT_NOCRT(log2)(RTStrNanDouble("234", false)), RTStrNanDouble("234", false));
|
---|
3073 | CHECK_DBL( RT_NOCRT(log2)(RTStrNanDouble("999s", false)), RTStrNanDouble("999s", false));
|
---|
3074 | CHECK_DBL( RT_NOCRT(log2)(RTStrNanDouble("fffs", true)), RTStrNanDouble("fffs", true));
|
---|
3075 | CHECK_XCPT(CHECK_DBL(RT_NOCRT(log2)( +0.0), -INFINITY), RT_NOCRT_FE_DIVBYZERO, RT_NOCRT_FE_DIVBYZERO);
|
---|
3076 | CHECK_XCPT(CHECK_DBL(RT_NOCRT(log2)( -0.0), -INFINITY), RT_NOCRT_FE_DIVBYZERO, RT_NOCRT_FE_DIVBYZERO);
|
---|
3077 | CHECK_XCPT(CHECK_DBL(RT_NOCRT(log2)(-123.0), RTStrNanDouble(NULL, false)), RT_NOCRT_FE_INVALID, RT_NOCRT_FE_INVALID);
|
---|
3078 | CHECK_DBL( RT_NOCRT(log2)( 1.0), +0.0);
|
---|
3079 | CHECK_DBL( RT_NOCRT(log2)( 2.0), +1.0);
|
---|
3080 | CHECK_DBL( RT_NOCRT(log2)( 1024.0), +10.0);
|
---|
3081 | CHECK_DBL( RT_NOCRT(log2)( 1099511627776.0), +40.0); /* _1T */
|
---|
3082 | CHECK_DBL_SAME( log2,( 1.0));
|
---|
3083 | CHECK_DBL_SAME( log2,( 2.0));
|
---|
3084 | CHECK_DBL_SAME( log2,( 1024.0));
|
---|
3085 | CHECK_DBL_SAME( log2,( 1099511627776.0)); /* _1T */
|
---|
3086 | CHECK_DBL_SAME( log2,( 1.5));
|
---|
3087 | CHECK_DBL_SAME( log2,( 1.234485e-5));
|
---|
3088 | CHECK_DBL_SAME( log2,( 1.234485e+9));
|
---|
3089 | CHECK_DBL_SAME( log2,( 1.234485e+253));
|
---|
3090 | CHECK_DBL_SAME( log2,( +INFINITY));
|
---|
3091 | CHECK_DBL_SAME( log2,( -INFINITY));
|
---|
3092 | CHECK_DBL_SAME( log2,( +DBL_MAX));
|
---|
3093 | CHECK_DBL_SAME( log2,( -DBL_MAX));
|
---|
3094 | CHECK_DBL_SAME( log2,(RTStrNanDouble(NULL, true)));
|
---|
3095 | CHECK_DBL_SAME( log2,(RTStrNanDouble(NULL, false)));
|
---|
3096 | #if 0 /* UCRT doesn't preserve signalling NaN */
|
---|
3097 | CHECK_DBL_SAME( log2,(RTStrNanDouble("s", true)));
|
---|
3098 | CHECK_DBL_SAME( log2,(RTStrNanDouble("s", false)));
|
---|
3099 | #endif
|
---|
3100 |
|
---|
3101 | CHECK_FLT( RT_NOCRT(log2f)(RTStrNanFloat(NULL, true)), RTStrNanFloat(NULL, true));
|
---|
3102 | CHECK_FLT( RT_NOCRT(log2f)(RTStrNanFloat("234", false)), RTStrNanFloat("234", false));
|
---|
3103 | CHECK_FLT( RT_NOCRT(log2f)(RTStrNanFloat("999s", false)), RTStrNanFloat("999s", false));
|
---|
3104 | CHECK_FLT( RT_NOCRT(log2f)(RTStrNanFloat("fffs", true)), RTStrNanFloat("fffs", true));
|
---|
3105 | CHECK_XCPT(CHECK_FLT(RT_NOCRT(log2f)( +0.0f), -(float)INFINITY), RT_NOCRT_FE_DIVBYZERO, RT_NOCRT_FE_DIVBYZERO);
|
---|
3106 | CHECK_XCPT(CHECK_FLT(RT_NOCRT(log2f)( -0.0f), -(float)INFINITY), RT_NOCRT_FE_DIVBYZERO, RT_NOCRT_FE_DIVBYZERO);
|
---|
3107 | CHECK_XCPT(CHECK_FLT(RT_NOCRT(log2f)(-123.0f), RTStrNanFloat(NULL, false)), RT_NOCRT_FE_INVALID, RT_NOCRT_FE_INVALID);
|
---|
3108 | CHECK_FLT( RT_NOCRT(log2f)( 1.0f), +0.0f);
|
---|
3109 | CHECK_FLT( RT_NOCRT(log2f)( 2.0f), +1.0f);
|
---|
3110 | CHECK_FLT( RT_NOCRT(log2f)( 1024.0f), +10.0f);
|
---|
3111 | CHECK_FLT( RT_NOCRT(log2f)( 1099511627776.0f), +40.0f); /* _1T */
|
---|
3112 | CHECK_FLT_SAME( log2f,( 1.0f));
|
---|
3113 | CHECK_FLT_SAME( log2f,( 2.0f));
|
---|
3114 | CHECK_FLT_SAME( log2f,( 1024.0f));
|
---|
3115 | CHECK_FLT_SAME( log2f,( 1099511627776.0f)); /* _1T */
|
---|
3116 | CHECK_FLT_SAME( log2f,( 1.5f));
|
---|
3117 | CHECK_FLT_SAME( log2f,( 1.234485e-5f));
|
---|
3118 | CHECK_FLT_SAME( log2f,( 1.234485e+9f));
|
---|
3119 | CHECK_FLT_SAME( log2f,( 1.234485e+35f));
|
---|
3120 | CHECK_FLT_SAME_RELAXED_NAN( log2f,( +(float)INFINITY)); /* UCRT returns +QNaN here, but log2 reutrn -QNaN. */
|
---|
3121 | CHECK_FLT_SAME_RELAXED_NAN( log2f,( -(float)INFINITY)); /* ditto */
|
---|
3122 | CHECK_FLT_SAME( log2f,( +FLT_MAX));
|
---|
3123 | CHECK_FLT_SAME_RELAXED_NAN( log2f,( -FLT_MAX)); /* UCRT returns +QNaN here, but log2 reutrn -QNaN. */
|
---|
3124 | CHECK_FLT_SAME( log2f,(RTStrNanFloat(NULL, true)));
|
---|
3125 | CHECK_FLT_SAME( log2f,(RTStrNanFloat(NULL, false)));
|
---|
3126 | #if 0 /* UCRT doesn't preserve signalling NaN */
|
---|
3127 | CHECK_FLT_SAME( log2f,(RTStrNanDouble("s", true)));
|
---|
3128 | CHECK_FLT_SAME( log2f,(RTStrNanDouble("s", false)));
|
---|
3129 | #endif
|
---|
3130 |
|
---|
3131 | }
|
---|
3132 |
|
---|
3133 |
|
---|
3134 | void testSqRt()
|
---|
3135 | {
|
---|
3136 | RTTestSub(g_hTest, "sqrt[f]");
|
---|
3137 |
|
---|
3138 | CHECK_DBL(RT_NOCRT(sqrt)( 1.0), +1.0);
|
---|
3139 | CHECK_DBL(RT_NOCRT(sqrt)( 4.0), +2.0);
|
---|
3140 | CHECK_DBL(RT_NOCRT(sqrt)( 144.0), +12.0);
|
---|
3141 | CHECK_DBL(RT_NOCRT(sqrt)( -1.0), RTStrNanDouble(NULL, false));
|
---|
3142 | CHECK_DBL(RT_NOCRT(sqrt)( -995.4547), RTStrNanDouble(NULL, false));
|
---|
3143 | CHECK_DBL_SAME( sqrt,( 1.0));
|
---|
3144 | CHECK_DBL_SAME( sqrt,( 1.5));
|
---|
3145 | CHECK_DBL_SAME( sqrt,( +0.0));
|
---|
3146 | CHECK_DBL_SAME( sqrt,( +0.0));
|
---|
3147 | CHECK_DBL_SAME( sqrt,( -0.0));
|
---|
3148 | CHECK_DBL_SAME( sqrt,( -0.0));
|
---|
3149 | CHECK_DBL_SAME( sqrt,( 999999.0));
|
---|
3150 | CHECK_DBL_SAME( sqrt,( -999999.0));
|
---|
3151 | CHECK_DBL_SAME( sqrt,( -999999.0));
|
---|
3152 | CHECK_DBL_SAME( sqrt,( 999999.0));
|
---|
3153 | CHECK_DBL_SAME( sqrt,( 39560.32334));
|
---|
3154 | CHECK_DBL_SAME( sqrt,( 39560.32334));
|
---|
3155 | CHECK_DBL_SAME( sqrt,( +INFINITY));
|
---|
3156 | CHECK_DBL_SAME( sqrt,( -INFINITY));
|
---|
3157 | CHECK_DBL_SAME( sqrt,( +DBL_MAX));
|
---|
3158 | CHECK_DBL_SAME( sqrt,( -DBL_MAX));
|
---|
3159 | CHECK_DBL_SAME( sqrt,(2.34960584706e100));
|
---|
3160 | CHECK_DBL_SAME( sqrt,(2.34960584706e300));
|
---|
3161 | CHECK_DBL_SAME( sqrt,(2.34960584706e300));
|
---|
3162 | CHECK_DBL_SAME( sqrt,(RTStrNanDouble(NULL, true)));
|
---|
3163 | CHECK_DBL_SAME( sqrt,(RTStrNanDouble("s", true)));
|
---|
3164 | CHECK_DBL_SAME( sqrt,(RTStrNanDouble("s", false)));
|
---|
3165 |
|
---|
3166 | CHECK_FLT(RT_NOCRT(sqrtf)( 1.0f), +1.0f);
|
---|
3167 | CHECK_FLT(RT_NOCRT(sqrtf)( 4.0f), +2.0f);
|
---|
3168 | CHECK_FLT(RT_NOCRT(sqrtf)( 144.0f), +12.0f);
|
---|
3169 | CHECK_FLT(RT_NOCRT(sqrtf)( -1.0f), RTStrNanDouble(NULL, false));
|
---|
3170 | CHECK_FLT(RT_NOCRT(sqrtf)( -995.4547f), RTStrNanDouble(NULL, false));
|
---|
3171 | CHECK_FLT_SAME( sqrtf,( 1.0f));
|
---|
3172 | CHECK_FLT_SAME( sqrtf,( 1.5f));
|
---|
3173 | CHECK_FLT_SAME( sqrtf,( +0.0f));
|
---|
3174 | CHECK_FLT_SAME( sqrtf,( +0.0f));
|
---|
3175 | CHECK_FLT_SAME( sqrtf,( -0.0f));
|
---|
3176 | CHECK_FLT_SAME( sqrtf,( -0.0f));
|
---|
3177 | CHECK_FLT_SAME( sqrtf,( 999999.0f));
|
---|
3178 | CHECK_FLT_SAME( sqrtf,( -999999.0f));
|
---|
3179 | CHECK_FLT_SAME( sqrtf,( -999999.0f));
|
---|
3180 | CHECK_FLT_SAME( sqrtf,( 999999.0f));
|
---|
3181 | CHECK_FLT_SAME( sqrtf,( 39560.32334f));
|
---|
3182 | CHECK_FLT_SAME( sqrtf,( 39560.32334f));
|
---|
3183 | CHECK_FLT_SAME( sqrtf,( +INFINITY));
|
---|
3184 | CHECK_FLT_SAME( sqrtf,( -INFINITY));
|
---|
3185 | CHECK_FLT_SAME( sqrtf,( +FLT_MAX));
|
---|
3186 | CHECK_FLT_SAME( sqrtf,( -FLT_MAX));
|
---|
3187 | CHECK_FLT_SAME( sqrtf,(2.34960584706e+10f));
|
---|
3188 | CHECK_FLT_SAME( sqrtf,(2.34960584706e+30f));
|
---|
3189 | CHECK_FLT_SAME( sqrtf,(2.34960584706e+30f));
|
---|
3190 | CHECK_FLT_SAME( sqrtf,(RTStrNanDouble(NULL, true)));
|
---|
3191 | CHECK_FLT_SAME( sqrtf,(RTStrNanDouble("s", true)));
|
---|
3192 | CHECK_FLT_SAME( sqrtf,(RTStrNanDouble("s", false)));
|
---|
3193 | }
|
---|
3194 |
|
---|
3195 |
|
---|
3196 | void testATan()
|
---|
3197 | {
|
---|
3198 | RTTestSub(g_hTest, "atan[f]");
|
---|
3199 |
|
---|
3200 | CHECK_DBL(RT_NOCRT(atan)( +1.0), +M_PI_4);
|
---|
3201 | CHECK_DBL(RT_NOCRT(atan)( -1.0), -M_PI_4);
|
---|
3202 | CHECK_DBL(RT_NOCRT(atan)( +INFINITY), +M_PI_2);
|
---|
3203 | CHECK_DBL(RT_NOCRT(atan)( -INFINITY), -M_PI_2);
|
---|
3204 | CHECK_DBL_SAME( atan,( 1.0));
|
---|
3205 | CHECK_DBL_SAME( atan,( 1.5));
|
---|
3206 | CHECK_DBL_SAME( atan,( +0.0));
|
---|
3207 | CHECK_DBL_SAME( atan,( +0.0));
|
---|
3208 | CHECK_DBL_SAME( atan,( -0.0));
|
---|
3209 | CHECK_DBL_SAME( atan,( -0.0));
|
---|
3210 | CHECK_DBL_SAME( atan,( 238.6634566));
|
---|
3211 | CHECK_DBL_SAME( atan,( -49.4578999));
|
---|
3212 | CHECK_DBL_SAME( atan,( 999999.0));
|
---|
3213 | CHECK_DBL_SAME( atan,( -999999.0));
|
---|
3214 | CHECK_DBL_SAME( atan,( -999999.0));
|
---|
3215 | CHECK_DBL_SAME( atan,( 999999.0));
|
---|
3216 | CHECK_DBL_SAME( atan,( 39560.32334));
|
---|
3217 | CHECK_DBL_SAME( atan,( 39560.32334));
|
---|
3218 | CHECK_DBL_SAME( atan,( +INFINITY));
|
---|
3219 | CHECK_DBL_SAME( atan,( -INFINITY));
|
---|
3220 | CHECK_DBL_SAME( atan,( +DBL_MAX));
|
---|
3221 | CHECK_DBL_SAME( atan,( -DBL_MAX));
|
---|
3222 | CHECK_DBL_SAME( atan,(2.34960584706e100));
|
---|
3223 | CHECK_DBL_SAME( atan,(2.34960584706e300));
|
---|
3224 | CHECK_DBL_SAME( atan,(2.34960584706e300));
|
---|
3225 | CHECK_DBL_SAME( atan,(RTStrNanDouble(NULL, true)));
|
---|
3226 | CHECK_DBL_SAME( atan,(RTStrNanDouble("s", true)));
|
---|
3227 | CHECK_DBL_SAME( atan,(RTStrNanDouble("s", false)));
|
---|
3228 |
|
---|
3229 | CHECK_DBL(RT_NOCRT(atanf)( +1.0f), (float)+M_PI_4);
|
---|
3230 | CHECK_DBL(RT_NOCRT(atanf)( -1.0f), (float)-M_PI_4);
|
---|
3231 | CHECK_DBL(RT_NOCRT(atanf)( +INFINITY), (float)+M_PI_2);
|
---|
3232 | CHECK_DBL(RT_NOCRT(atanf)( -INFINITY), (float)-M_PI_2);
|
---|
3233 | CHECK_DBL_SAME( atanf,( 1.0f));
|
---|
3234 | CHECK_DBL_SAME( atanf,( 1.5f));
|
---|
3235 | CHECK_DBL_SAME( atanf,( +0.0f));
|
---|
3236 | CHECK_DBL_SAME( atanf,( +0.0f));
|
---|
3237 | CHECK_DBL_SAME( atanf,( -0.0f));
|
---|
3238 | CHECK_DBL_SAME( atanf,( -0.0f));
|
---|
3239 | CHECK_DBL_SAME( atanf,( 238.6634566f));
|
---|
3240 | CHECK_DBL_SAME( atanf,( -49.4578999f));
|
---|
3241 | CHECK_DBL_SAME( atanf,( 999999.0f));
|
---|
3242 | CHECK_DBL_SAME( atanf,( -999999.0f));
|
---|
3243 | CHECK_DBL_SAME( atanf,( -999999.0f));
|
---|
3244 | CHECK_DBL_SAME( atanf,( 999999.0f));
|
---|
3245 | CHECK_DBL_SAME( atanf,( 39560.32334f));
|
---|
3246 | CHECK_DBL_SAME( atanf,( 39560.32334f));
|
---|
3247 | CHECK_DBL_SAME( atanf,( +INFINITY));
|
---|
3248 | CHECK_DBL_SAME( atanf,( -INFINITY));
|
---|
3249 | CHECK_DBL_SAME( atanf,( +FLT_MAX));
|
---|
3250 | CHECK_DBL_SAME( atanf,( -FLT_MAX));
|
---|
3251 | CHECK_DBL_SAME( atanf,(2.34960584706e+10f));
|
---|
3252 | CHECK_DBL_SAME( atanf,(2.34960584706e+30f));
|
---|
3253 | CHECK_DBL_SAME( atanf,(2.34960584706e+30f));
|
---|
3254 | CHECK_DBL_SAME( atanf,(RTStrNanFloat(NULL, true)));
|
---|
3255 | CHECK_DBL_SAME( atanf,(RTStrNanFloat("s", true)));
|
---|
3256 | CHECK_DBL_SAME( atanf,(RTStrNanFloat("s", false)));
|
---|
3257 | }
|
---|
3258 |
|
---|
3259 |
|
---|
3260 | void testATan2()
|
---|
3261 | {
|
---|
3262 | RTTestSub(g_hTest, "atan2[f]");
|
---|
3263 |
|
---|
3264 | CHECK_DBL(RT_NOCRT(atan2)( +1.0, 0.0), +M_PI_2);
|
---|
3265 | CHECK_DBL(RT_NOCRT(atan2)( -1.0, 0.0), -M_PI_2);
|
---|
3266 | CHECK_DBL(RT_NOCRT(atan2)( +1.0, +1.0), +M_PI_4);
|
---|
3267 | CHECK_DBL(RT_NOCRT(atan2)( -1.0, -1.0), -M_PI_2 - M_PI_4);
|
---|
3268 | CHECK_DBL_SAME( atan2,( +1.0, 0.0));
|
---|
3269 | CHECK_DBL_SAME( atan2,( +1.0, -0.0));
|
---|
3270 | CHECK_DBL_SAME( atan2,( -1.0, 0.0));
|
---|
3271 | CHECK_DBL_SAME( atan2,( -1.0, -0.0));
|
---|
3272 | CHECK_DBL_SAME( atan2,( +1.0, +1.0));
|
---|
3273 | CHECK_DBL_SAME( atan2,( -1.0, +1.0));
|
---|
3274 | CHECK_DBL_SAME( atan2,( +1.0, -1.0));
|
---|
3275 | CHECK_DBL_SAME( atan2,( -1.0, -1.0));
|
---|
3276 | CHECK_DBL_SAME( atan2,( 238.6634566, -999999.0));
|
---|
3277 | CHECK_DBL_SAME( atan2,( -905698045.1, 490876.0));
|
---|
3278 | CHECK_DBL_SAME( atan2,( 1.333334e-10, -1.9993e+200));
|
---|
3279 | CHECK_DBL_SAME( atan2,( 1.333334e+168, -1.9993e+299));
|
---|
3280 | CHECK_DBL_SAME( atan2,( +DBL_MAX, +DBL_MAX));
|
---|
3281 | CHECK_DBL_SAME( atan2,( -DBL_MAX, +DBL_MAX));
|
---|
3282 | CHECK_DBL_SAME( atan2,( +INFINITY, +INFINITY));
|
---|
3283 | CHECK_DBL_SAME( atan2,( -INFINITY, +INFINITY));
|
---|
3284 | CHECK_DBL_SAME( atan2,( -INFINITY, 42.242424));
|
---|
3285 | CHECK_DBL_SAME( atan2,(RTStrNanDouble(NULL, true), RTStrNanDouble(NULL, true)));
|
---|
3286 | CHECK_DBL_SAME( atan2,(RTStrNanDouble(NULL, false), RTStrNanDouble(NULL, false)));
|
---|
3287 | CHECK_DBL_SAME( atan2,(RTStrNanDouble(NULL, false), RTStrNanDouble(NULL, true)));
|
---|
3288 | //CHECK_DBL_SAME( atan2,(RTStrNanDouble(NULL, true), RTStrNanDouble(NULL, false))); - UCRT returns -QNaN, we +QNaN
|
---|
3289 | CHECK_DBL_SAME( atan2,(RTStrNanDouble(NULL, true), RTStrNanDouble("s", false)));
|
---|
3290 |
|
---|
3291 | CHECK_FLT(RT_NOCRT(atan2f)( +1.0f, 0.0f), (float)+M_PI_2);
|
---|
3292 | CHECK_FLT(RT_NOCRT(atan2f)( -1.0f, 0.0f), (float)-M_PI_2);
|
---|
3293 | CHECK_FLT(RT_NOCRT(atan2f)( +1.0f, +1.0f), (float)+M_PI_4);
|
---|
3294 | CHECK_FLT(RT_NOCRT(atan2f)( -1.0f, -1.0f), (float)(-M_PI_2 - M_PI_4));
|
---|
3295 | CHECK_FLT_SAME( atan2f,( +1.0f, 0.0f));
|
---|
3296 | CHECK_FLT_SAME( atan2f,( +1.0f, -0.0f));
|
---|
3297 | CHECK_FLT_SAME( atan2f,( -1.0f, 0.0f));
|
---|
3298 | CHECK_FLT_SAME( atan2f,( -1.0f, -0.0f));
|
---|
3299 | CHECK_FLT_SAME( atan2f,( +1.0f, +1.0f));
|
---|
3300 | CHECK_FLT_SAME( atan2f,( -1.0f, +1.0f));
|
---|
3301 | CHECK_FLT_SAME( atan2f,( +1.0f, -1.0f));
|
---|
3302 | CHECK_FLT_SAME( atan2f,( -1.0f, -1.0f));
|
---|
3303 | CHECK_FLT_SAME( atan2f,( 238.6634566f, -999999.0f));
|
---|
3304 | CHECK_FLT_SAME( atan2f,( -905698045.1f, 490876.0f));
|
---|
3305 | CHECK_FLT_SAME( atan2f,( 1.333334e-10f, -1.9993e+20f));
|
---|
3306 | CHECK_FLT_SAME( atan2f,( 1.333334e+35f, -1.9993e+29f));
|
---|
3307 | CHECK_FLT_SAME( atan2f,( +FLT_MAX, +FLT_MAX));
|
---|
3308 | CHECK_FLT_SAME( atan2f,( -FLT_MAX, +FLT_MAX));
|
---|
3309 | CHECK_FLT_SAME( atan2f,( +INFINITY, +INFINITY));
|
---|
3310 | CHECK_FLT_SAME( atan2f,( -INFINITY, +INFINITY));
|
---|
3311 | CHECK_FLT_SAME( atan2f,( -INFINITY, 42.242424f));
|
---|
3312 | CHECK_FLT_SAME( atan2f,(RTStrNanFloat(NULL, true), RTStrNanFloat(NULL, true)));
|
---|
3313 | CHECK_FLT_SAME( atan2f,(RTStrNanFloat(NULL, false), RTStrNanFloat(NULL, false)));
|
---|
3314 | CHECK_FLT_SAME( atan2f,(RTStrNanFloat(NULL, false), RTStrNanFloat(NULL, true)));
|
---|
3315 | //CHECK_FLT_SAME( atan2f,(RTStrNanFloat(NULL, true), RTStrNanFloat(NULL, false))); - UCRT returns -QNaN, we +QNaN
|
---|
3316 | CHECK_FLT_SAME( atan2f,(RTStrNanFloat(NULL, true), RTStrNanFloat("s", false)));
|
---|
3317 | }
|
---|
3318 |
|
---|
3319 |
|
---|
3320 | void testSin()
|
---|
3321 | {
|
---|
3322 | RTTestSub(g_hTest, "sin[f]");
|
---|
3323 |
|
---|
3324 | /*
|
---|
3325 | * Note! sin, cos and friends are complicated the results may differ between
|
---|
3326 | * implementations. The numbers below was computed using amd64 glibc
|
---|
3327 | * (2.27-3ubuntu1.4) sinl() and a %.33Lf printf.
|
---|
3328 | *
|
---|
3329 | * Our code is based on the x87 CPU and does not have the best
|
---|
3330 | * reduction code is inaccurate, so accuracy drops. Also, with the
|
---|
3331 | * input accuracy difference we must expect differences too.
|
---|
3332 | */
|
---|
3333 | CHECK_DBL( RT_NOCRT(sin)( +0.0), +0.0);
|
---|
3334 | CHECK_DBL( RT_NOCRT(sin)( -0.0), -0.0);
|
---|
3335 | CHECK_DBL( RT_NOCRT(sin)( +M_PI), +0.0);
|
---|
3336 | CHECK_DBL( RT_NOCRT(sin)( -M_PI), +0.0);
|
---|
3337 | CHECK_DBL( RT_NOCRT(sin)( +M_PI_2), +1.0);
|
---|
3338 | CHECK_DBL( RT_NOCRT(sin)( -M_PI_2), -1.0);
|
---|
3339 | CHECK_DBL( RT_NOCRT(sin)( +M_PI_2 + M_PI*4), +1.0);
|
---|
3340 | CHECK_DBL( RT_NOCRT(sin)( -M_PI_2 - M_PI*4), -1.0);
|
---|
3341 |
|
---|
3342 | CHECK_DBL( RT_NOCRT(sin)( +M_PI_2 + M_PI*2), +1.0);
|
---|
3343 | CHECK_DBL( RT_NOCRT(sin)( -M_PI_2 - M_PI*2), -1.0);
|
---|
3344 | CHECK_DBL( RT_NOCRT(sin)( +1.0), +0.84147098480789650488);
|
---|
3345 | CHECK_DBL( RT_NOCRT(sin)( +2.0), +0.90929742682568170942);
|
---|
3346 | CHECK_DBL( RT_NOCRT(sin)( +3.0), +0.14112000805986721352);
|
---|
3347 | CHECK_DBL( RT_NOCRT(sin)( +4.0), -0.75680249530792820245);
|
---|
3348 | CHECK_DBL( RT_NOCRT(sin)( +5.0), -0.95892427466313845397);
|
---|
3349 | CHECK_DBL( RT_NOCRT(sin)( +6.0), -0.27941549819892586015);
|
---|
3350 | CHECK_DBL( RT_NOCRT(sin)( +7.0), +0.65698659871878906102);
|
---|
3351 | CHECK_DBL( RT_NOCRT(sin)( +8.0), +0.98935824662338178737);
|
---|
3352 | CHECK_DBL( RT_NOCRT(sin)( +9.0), +0.41211848524175659358);
|
---|
3353 | CHECK_DBL( RT_NOCRT(sin)( +10.0), -0.54402111088936977445);
|
---|
3354 | CHECK_DBL( RT_NOCRT(sin)( +100.0), -0.50636564110975879061);
|
---|
3355 | CHECK_DBL( RT_NOCRT(sin)( +654.216812456), +0.69292681127157818022);
|
---|
3356 | CHECK_DBL( RT_NOCRT(sin)( 10.1010101010101010101010), -0.62585878258501614901);
|
---|
3357 | CHECK_DBL( RT_NOCRT(sin)( +25.2525252525252525252525), +0.11949778146891366915);
|
---|
3358 | CHECK_DBL( RT_NOCRT(sin)( +252.2525252525252525252525), +0.79868874455343841223);
|
---|
3359 | CHECK_DBL( RT_NOCRT(sin)( +2525.2525252525252525252525), -0.55467159842968405403);
|
---|
3360 | CHECK_DBL_RANGE(RT_NOCRT(sin)( +25252.2525252525252525252525), +0.13040325588994761130, 0.0000000000000010000);
|
---|
3361 | CHECK_DBL_RANGE(RT_NOCRT(sin)(+252525.2525252525252525252525), -0.77923047482990159818, 0.0000000000000100000);
|
---|
3362 |
|
---|
3363 | CHECK_DBL( RT_NOCRT(sin)( -1.0), -0.84147098480789650488);
|
---|
3364 | CHECK_DBL( RT_NOCRT(sin)( -2.0), -0.90929742682568170942);
|
---|
3365 | CHECK_DBL( RT_NOCRT(sin)( -3.0), -0.14112000805986721352);
|
---|
3366 | CHECK_DBL( RT_NOCRT(sin)( -4.0), +0.75680249530792820245);
|
---|
3367 | CHECK_DBL( RT_NOCRT(sin)( -5.0), +0.95892427466313845397);
|
---|
3368 | CHECK_DBL( RT_NOCRT(sin)( -6.0), +0.27941549819892586015);
|
---|
3369 | CHECK_DBL( RT_NOCRT(sin)( -7.0), -0.65698659871878906102);
|
---|
3370 | CHECK_DBL( RT_NOCRT(sin)( -8.0), -0.98935824662338178737);
|
---|
3371 | CHECK_DBL( RT_NOCRT(sin)( -9.0), -0.41211848524175659358);
|
---|
3372 | CHECK_DBL( RT_NOCRT(sin)( -10.0), +0.54402111088936977445);
|
---|
3373 | CHECK_DBL( RT_NOCRT(sin)( -100.0), +0.50636564110975879061);
|
---|
3374 | CHECK_DBL( RT_NOCRT(sin)( -654.216812456), -0.69292681127157818022);
|
---|
3375 | CHECK_DBL( RT_NOCRT(sin)( -10.1010101010101010101010), +0.62585878258501614901);
|
---|
3376 | CHECK_DBL( RT_NOCRT(sin)( -25.2525252525252525252525), -0.11949778146891366915);
|
---|
3377 | CHECK_DBL( RT_NOCRT(sin)( -252.2525252525252525252525), -0.79868874455343841223);
|
---|
3378 | CHECK_DBL( RT_NOCRT(sin)( -2525.2525252525252525252525), +0.55467159842968405403);
|
---|
3379 | CHECK_DBL_RANGE(RT_NOCRT(sin)( -25252.2525252525252525252525), -0.13040325588994761130, 0.0000000000000010000);
|
---|
3380 | CHECK_DBL_RANGE(RT_NOCRT(sin)(-252525.2525252525252525252525), +0.77923047482990159818, 0.0000000000000100000);
|
---|
3381 | CHECK_DBL( RT_NOCRT(sin)( RTStrNanDouble("s", true)), RTStrNanDouble("s", true));
|
---|
3382 | CHECK_DBL( RT_NOCRT(sin)(RTStrNanDouble("9999s", false)), RTStrNanDouble("9999s", false));
|
---|
3383 |
|
---|
3384 | CHECK_DBL_SAME( sin,( 1.0));
|
---|
3385 | CHECK_DBL_SAME( sin,( 1.5));
|
---|
3386 | CHECK_DBL_SAME( sin,( +0.0));
|
---|
3387 | CHECK_DBL_SAME( sin,( +0.0));
|
---|
3388 | CHECK_DBL_SAME( sin,( -0.0));
|
---|
3389 | CHECK_DBL_SAME( sin,( -0.0));
|
---|
3390 | CHECK_DBL_SAME( sin,( -10.0));
|
---|
3391 | #if 0 /* UCRT returns tiny fractions for these in the 2**-53 range, we return 0.0 */
|
---|
3392 | CHECK_DBL_SAME( sin,( +M_PI));
|
---|
3393 | CHECK_DBL_SAME( sin,( -M_PI));
|
---|
3394 | #endif
|
---|
3395 | CHECK_DBL_SAME( sin,( +M_PI_2));
|
---|
3396 | CHECK_DBL_SAME( sin,( -M_PI_2));
|
---|
3397 | CHECK_DBL_SAME( sin,( +INFINITY));
|
---|
3398 | CHECK_DBL_SAME( sin,( -INFINITY));
|
---|
3399 | CHECK_DBL_SAME( sin,(RTStrNanDouble(NULL, true)));
|
---|
3400 | #if 0 /*UCRT converts these to quiet ones, we check above */
|
---|
3401 | //CHECK_DBL_SAME( sin,(RTStrNanDouble("s", true)));
|
---|
3402 | //CHECK_DBL_SAME( sin,(RTStrNanDouble("s", false)));
|
---|
3403 | #endif
|
---|
3404 |
|
---|
3405 |
|
---|
3406 | CHECK_FLT( RT_NOCRT(sinf)( +0.0f), +0.0f);
|
---|
3407 | CHECK_FLT( RT_NOCRT(sinf)( -0.0f), -0.0f);
|
---|
3408 | CHECK_FLT( RT_NOCRT(sinf)( (float)+M_PI), +0.0f);
|
---|
3409 | CHECK_FLT( RT_NOCRT(sinf)( (float)-M_PI), +0.0f);
|
---|
3410 | CHECK_FLT( RT_NOCRT(sinf)( (float)+M_PI_2), +1.0f);
|
---|
3411 | CHECK_FLT( RT_NOCRT(sinf)( (float)-M_PI_2), -1.0f);
|
---|
3412 | CHECK_FLT( RT_NOCRT(sinf)( (float)(+M_PI_2 + M_PI*4)), +1.0f);
|
---|
3413 | CHECK_FLT( RT_NOCRT(sinf)( (float)(-M_PI_2 - M_PI*4)), -1.0f);
|
---|
3414 |
|
---|
3415 | CHECK_FLT( RT_NOCRT(sinf)( (float)(+M_PI_2 + M_PI*2)), +1.0f);
|
---|
3416 | CHECK_FLT( RT_NOCRT(sinf)( (float)(-M_PI_2 - M_PI*2)), -1.0f);
|
---|
3417 | CHECK_FLT( RT_NOCRT(sinf)( +1.0f), +0.841470956802368f);
|
---|
3418 | CHECK_FLT( RT_NOCRT(sinf)( +2.0f), +0.909297406673431f);
|
---|
3419 | CHECK_FLT( RT_NOCRT(sinf)( +3.0f), +0.141120001673698f);
|
---|
3420 | CHECK_FLT( RT_NOCRT(sinf)( +4.0f), -0.756802499294281f);
|
---|
3421 | CHECK_FLT( RT_NOCRT(sinf)( +5.0f), -0.958924293518066f);
|
---|
3422 | CHECK_FLT( RT_NOCRT(sinf)( +6.0f), -0.279415488243103f);
|
---|
3423 | CHECK_FLT( RT_NOCRT(sinf)( +7.0f), +0.656986594200134f);
|
---|
3424 | CHECK_FLT( RT_NOCRT(sinf)( +8.0f), +0.989358246326447f);
|
---|
3425 | CHECK_FLT( RT_NOCRT(sinf)( +9.0f), +0.412118494510651f);
|
---|
3426 | CHECK_FLT( RT_NOCRT(sinf)( +10.0f), -0.544021129608154f);
|
---|
3427 | CHECK_FLT( RT_NOCRT(sinf)( +100.0f), -0.506365656852722f);
|
---|
3428 | CHECK_FLT( RT_NOCRT(sinf)( +654.216812456f), +0.692915558815002f);
|
---|
3429 | CHECK_FLT( RT_NOCRT(sinf)( 10.10101010101010f), -0.625858962535858f);
|
---|
3430 | CHECK_FLT( RT_NOCRT(sinf)( +25.25252525252525f), +0.119497857987881f);
|
---|
3431 | CHECK_FLT( RT_NOCRT(sinf)( +252.25252525252525f), +0.798684179782867f);
|
---|
3432 | CHECK_FLT( RT_NOCRT(sinf)( +2525.25252525252525f), -0.554741382598877f);
|
---|
3433 | CHECK_FLT( RT_NOCRT(sinf)( +25252.25252525252525f), +0.129835993051529f);
|
---|
3434 | CHECK_FLT( RT_NOCRT(sinf)( +252525.25252525252525f), -0.777645349502563f);
|
---|
3435 |
|
---|
3436 | CHECK_FLT( RT_NOCRT(sinf)( -1.0f), -0.841470956802368f);
|
---|
3437 | CHECK_FLT( RT_NOCRT(sinf)( -2.0f), -0.909297406673431f);
|
---|
3438 | CHECK_FLT( RT_NOCRT(sinf)( -3.0f), -0.141120001673698f);
|
---|
3439 | CHECK_FLT( RT_NOCRT(sinf)( -4.0f), +0.756802499294281f);
|
---|
3440 | CHECK_FLT( RT_NOCRT(sinf)( -5.0f), +0.958924293518066f);
|
---|
3441 | CHECK_FLT( RT_NOCRT(sinf)( -6.0f), +0.279415488243103f);
|
---|
3442 | CHECK_FLT( RT_NOCRT(sinf)( -7.0f), -0.656986594200134f);
|
---|
3443 | CHECK_FLT( RT_NOCRT(sinf)( -8.0f), -0.989358246326447f);
|
---|
3444 | CHECK_FLT( RT_NOCRT(sinf)( -9.0f), -0.412118494510651f);
|
---|
3445 | CHECK_FLT( RT_NOCRT(sinf)( -10.0f), +0.544021129608154f);
|
---|
3446 | CHECK_FLT( RT_NOCRT(sinf)( -100.0f), +0.506365656852722f);
|
---|
3447 | CHECK_FLT( RT_NOCRT(sinf)( -654.216812456f), -0.692915558815002f);
|
---|
3448 | CHECK_FLT( RT_NOCRT(sinf)( -10.10101010101010f), +0.625858962535858f);
|
---|
3449 | CHECK_FLT( RT_NOCRT(sinf)( -25.25252525252525f), -0.119497857987881f);
|
---|
3450 | CHECK_FLT( RT_NOCRT(sinf)( -252.25252525252525f), -0.798684179782867f);
|
---|
3451 | CHECK_FLT( RT_NOCRT(sinf)( -2525.25252525252525f), +0.554741382598877f);
|
---|
3452 | CHECK_FLT( RT_NOCRT(sinf)( -25252.25252525252525f), -0.129835993051529f);
|
---|
3453 | CHECK_FLT( RT_NOCRT(sinf)( -252525.25252525252525f), +0.777645349502563f);
|
---|
3454 | CHECK_FLT( RT_NOCRT(sinf)( RTStrNanDouble("s", true)), RTStrNanDouble("s", true));
|
---|
3455 | CHECK_FLT( RT_NOCRT(sinf)( RTStrNanDouble("9999s", false)), RTStrNanDouble("9999s", false));
|
---|
3456 |
|
---|
3457 | CHECK_FLT_SAME( sinf,( 1.0f));
|
---|
3458 | CHECK_FLT_SAME( sinf,( 1.5f));
|
---|
3459 | CHECK_FLT_SAME( sinf,( +0.0f));
|
---|
3460 | CHECK_FLT_SAME( sinf,( +0.0f));
|
---|
3461 | CHECK_FLT_SAME( sinf,( -0.0f));
|
---|
3462 | CHECK_FLT_SAME( sinf,( -0.0f));
|
---|
3463 | CHECK_FLT_SAME( sinf,( -10.0f));
|
---|
3464 | #if 0 /* UCRT returns tiny fractions for these in the 2**-53 range, we return 0.0 */
|
---|
3465 | CHECK_FLT_SAME( sinf,( (float)+M_PI));
|
---|
3466 | CHECK_FLT_SAME( sinf,( (float)-M_PI));
|
---|
3467 | #endif
|
---|
3468 | CHECK_FLT_SAME( sinf,( (float)+M_PI_2));
|
---|
3469 | CHECK_FLT_SAME( sinf,( (float)-M_PI_2));
|
---|
3470 | CHECK_FLT_SAME( sinf,( (float)+INFINITY));
|
---|
3471 | CHECK_FLT_SAME( sinf,( (float)-INFINITY));
|
---|
3472 | CHECK_FLT_SAME( sinf,(RTStrNanDouble(NULL, true)));
|
---|
3473 | #if 0 /*UCRT converts these to quiet ones, we check above */
|
---|
3474 | //CHECK_FLT_SAME( sin,(RTStrNanDouble("s", true)));
|
---|
3475 | //CHECK_FLT_SAME( sin,(RTStrNanDouble("s", false)));
|
---|
3476 | #endif
|
---|
3477 | }
|
---|
3478 |
|
---|
3479 |
|
---|
3480 | void testCos()
|
---|
3481 | {
|
---|
3482 | RTTestSub(g_hTest, "cos[f]");
|
---|
3483 |
|
---|
3484 | /* See comment in testSin regarding testing and accuracy. */
|
---|
3485 | CHECK_DBL( RT_NOCRT(cos)( +0.0), +1.0);
|
---|
3486 | CHECK_DBL( RT_NOCRT(cos)( -0.0), +1.0);
|
---|
3487 | CHECK_DBL( RT_NOCRT(cos)( +M_PI), -1.0);
|
---|
3488 | CHECK_DBL( RT_NOCRT(cos)( -M_PI), -1.0);
|
---|
3489 | CHECK_DBL( RT_NOCRT(cos)( +M_PI_2), 0.0);
|
---|
3490 | CHECK_DBL( RT_NOCRT(cos)( -M_PI_2), 0.0);
|
---|
3491 | CHECK_DBL( RT_NOCRT(cos)( +(M_PI_2 + M_PI*4)), 0.0);
|
---|
3492 | CHECK_DBL( RT_NOCRT(cos)( -(M_PI_2 + M_PI*4)), 0.0);
|
---|
3493 | CHECK_DBL( RT_NOCRT(cos)( +(M_PI_2 + M_PI*2)), 0.0);
|
---|
3494 | CHECK_DBL( RT_NOCRT(cos)( -(M_PI_2 + M_PI*2)), 0.0);
|
---|
3495 | CHECK_DBL( RT_NOCRT(cos)( +1.0), +0.54030230586813976501);
|
---|
3496 | CHECK_DBL( RT_NOCRT(cos)( +2.0), -0.41614683654714240690);
|
---|
3497 | CHECK_DBL( RT_NOCRT(cos)( +3.0), -0.98999249660044541521);
|
---|
3498 | CHECK_DBL( RT_NOCRT(cos)( +4.0), -0.65364362086361194049);
|
---|
3499 | CHECK_DBL( RT_NOCRT(cos)( +5.0), +0.28366218546322624627);
|
---|
3500 | CHECK_DBL( RT_NOCRT(cos)( +6.0), +0.96017028665036596724);
|
---|
3501 | CHECK_DBL( RT_NOCRT(cos)( +7.0), +0.75390225434330460086);
|
---|
3502 | CHECK_DBL( RT_NOCRT(cos)( +8.0), -0.14550003380861353808);
|
---|
3503 | CHECK_DBL( RT_NOCRT(cos)( +9.0), -0.91113026188467693967);
|
---|
3504 | CHECK_DBL( RT_NOCRT(cos)( +10.0), -0.83907152907645243811);
|
---|
3505 | CHECK_DBL( RT_NOCRT(cos)( +100.0), +0.86231887228768389075);
|
---|
3506 | CHECK_DBL( RT_NOCRT(cos)( +654.216812456), +0.72100792937456847920);
|
---|
3507 | CHECK_DBL( RT_NOCRT(cos)( 10.10101010101010), -0.77993639757431598714);
|
---|
3508 | CHECK_DBL( RT_NOCRT(cos)( +25.25252525252525), +0.99283446768532801485);
|
---|
3509 | CHECK_DBL( RT_NOCRT(cos)( +252.25252525252525), +0.60174437207476427769);
|
---|
3510 | CHECK_DBL( RT_NOCRT(cos)( +2525.25252525252525), +0.83206935882500765445);
|
---|
3511 | CHECK_DBL_RANGE(RT_NOCRT(cos)( +25252.25252525252525), +0.99146103849485722748, 0.0000000000000010000);
|
---|
3512 | CHECK_DBL_RANGE(RT_NOCRT(cos)( +252525.25252525252525), -0.62673747861155237882, 0.0000000000000100000);
|
---|
3513 | CHECK_DBL( RT_NOCRT(cos)( 3.14), -0.99999873172753950268);
|
---|
3514 | CHECK_DBL( RT_NOCRT(cos)( -1.0), +0.54030230586813976501);
|
---|
3515 | CHECK_DBL( RT_NOCRT(cos)( -2.0), -0.41614683654714240690);
|
---|
3516 | CHECK_DBL( RT_NOCRT(cos)( -3.0), -0.98999249660044541521);
|
---|
3517 | CHECK_DBL( RT_NOCRT(cos)( -4.0), -0.65364362086361194049);
|
---|
3518 | CHECK_DBL( RT_NOCRT(cos)( -5.0), +0.28366218546322624627);
|
---|
3519 | CHECK_DBL( RT_NOCRT(cos)( -6.0), +0.96017028665036596724);
|
---|
3520 | CHECK_DBL( RT_NOCRT(cos)( -7.0), +0.75390225434330460086);
|
---|
3521 | CHECK_DBL( RT_NOCRT(cos)( -8.0), -0.14550003380861353808);
|
---|
3522 | CHECK_DBL( RT_NOCRT(cos)( -9.0), -0.91113026188467693967);
|
---|
3523 | CHECK_DBL( RT_NOCRT(cos)( -10.0), -0.83907152907645243811);
|
---|
3524 | CHECK_DBL( RT_NOCRT(cos)( -100.0), +0.86231887228768389075);
|
---|
3525 | CHECK_DBL( RT_NOCRT(cos)( -654.216812456), +0.72100792937456847920);
|
---|
3526 | CHECK_DBL( RT_NOCRT(cos)( -10.10101010101010), -0.77993639757431598714);
|
---|
3527 | CHECK_DBL( RT_NOCRT(cos)( -25.25252525252525), +0.99283446768532801485);
|
---|
3528 | CHECK_DBL( RT_NOCRT(cos)( -252.25252525252525), +0.60174437207476427769);
|
---|
3529 | CHECK_DBL( RT_NOCRT(cos)( -2525.25252525252525), +0.83206935882500765445);
|
---|
3530 | CHECK_DBL_RANGE(RT_NOCRT(cos)( -25252.25252525252525), +0.99146103849485722748, 0.0000000000000010000);
|
---|
3531 | CHECK_DBL_RANGE(RT_NOCRT(cos)( -252525.25252525252525), -0.62673747861155237882, 0.0000000000000100000);
|
---|
3532 | CHECK_DBL( RT_NOCRT(cos)( -3.14), -0.99999873172753950268);
|
---|
3533 | CHECK_DBL( RT_NOCRT(cos)( RTStrNanDouble("123s", false)), RTStrNanDouble("123s", false));
|
---|
3534 | CHECK_DBL( RT_NOCRT(cos)( RTStrNanDouble("9991s", true)), RTStrNanDouble("9991s", true));
|
---|
3535 |
|
---|
3536 | CHECK_DBL_SAME( cos,( 1.0));
|
---|
3537 | CHECK_DBL_SAME( cos,( 1.5));
|
---|
3538 | CHECK_DBL_SAME( cos,( +0.0));
|
---|
3539 | CHECK_DBL_SAME( cos,( +0.0));
|
---|
3540 | CHECK_DBL_SAME( cos,( -0.0));
|
---|
3541 | CHECK_DBL_SAME( cos,( -0.0));
|
---|
3542 | CHECK_DBL_SAME( cos,( 238.6634566));
|
---|
3543 | CHECK_DBL_SAME( cos,( -49.4578999));
|
---|
3544 | CHECK_DBL_SAME( cos,( +M_PI));
|
---|
3545 | CHECK_DBL_SAME( cos,( -M_PI));
|
---|
3546 | #if 0 /* UCRT does not produce 0.0 here, but some 2**-54 value */
|
---|
3547 | CHECK_DBL_SAME( cos,( +M_PI_2));
|
---|
3548 | CHECK_DBL_SAME( cos,( -M_PI_2));
|
---|
3549 | #endif
|
---|
3550 | CHECK_DBL_SAME( cos,( +INFINITY));
|
---|
3551 | CHECK_DBL_SAME( cos,( -INFINITY));
|
---|
3552 | CHECK_DBL_SAME( cos,(RTStrNanDouble(NULL, false)));
|
---|
3553 | CHECK_DBL_SAME( cos,(RTStrNanDouble(NULL, true)));
|
---|
3554 |
|
---|
3555 |
|
---|
3556 | CHECK_FLT( RT_NOCRT(cosf)( +0.0f), +1.0f);
|
---|
3557 | CHECK_FLT( RT_NOCRT(cosf)( -0.0f), +1.0f);
|
---|
3558 | CHECK_FLT( RT_NOCRT(cosf)( +(float)M_PI), -1.0f);
|
---|
3559 | CHECK_FLT( RT_NOCRT(cosf)( -(float)M_PI), -1.0f);
|
---|
3560 | CHECK_FLT( RT_NOCRT(cosf)( +(float)M_PI_2), 0.0f);
|
---|
3561 | CHECK_FLT( RT_NOCRT(cosf)( -(float)M_PI_2), 0.0f);
|
---|
3562 | CHECK_FLT( RT_NOCRT(cosf)( +(float)(M_PI_2 + M_PI*4)), 0.0f);
|
---|
3563 | CHECK_FLT( RT_NOCRT(cosf)( -(float)(M_PI_2 + M_PI*4)), 0.0f);
|
---|
3564 | CHECK_FLT( RT_NOCRT(cosf)( +(float)(M_PI_2 + M_PI*2)), 0.0f);
|
---|
3565 | CHECK_FLT( RT_NOCRT(cosf)( -(float)(M_PI_2 + M_PI*2)), 0.0f);
|
---|
3566 | CHECK_FLT( RT_NOCRT(cosf)( +1.0f), +0.540302276611328f);
|
---|
3567 | CHECK_FLT( RT_NOCRT(cosf)( +2.0f), -0.416146844625473f);
|
---|
3568 | CHECK_FLT( RT_NOCRT(cosf)( +3.0f), -0.989992499351501f);
|
---|
3569 | CHECK_FLT( RT_NOCRT(cosf)( +4.0f), -0.653643608093262f);
|
---|
3570 | CHECK_FLT( RT_NOCRT(cosf)( +5.0f), +0.283662199974060f);
|
---|
3571 | CHECK_FLT( RT_NOCRT(cosf)( +6.0f), +0.960170269012451f);
|
---|
3572 | CHECK_FLT( RT_NOCRT(cosf)( +7.0f), +0.753902256488800f);
|
---|
3573 | CHECK_FLT( RT_NOCRT(cosf)( +8.0f), -0.145500034093857f);
|
---|
3574 | CHECK_FLT( RT_NOCRT(cosf)( +9.0f), -0.911130249500275f);
|
---|
3575 | CHECK_FLT( RT_NOCRT(cosf)( +10.0f), -0.839071512222290f);
|
---|
3576 | CHECK_FLT( RT_NOCRT(cosf)( +100.0f), +0.862318873405457f);
|
---|
3577 | CHECK_FLT( RT_NOCRT(cosf)( +654.216812456f), +0.721018731594086f);
|
---|
3578 | CHECK_FLT( RT_NOCRT(cosf)( 10.10101010101010f), -0.779936254024506f);
|
---|
3579 | CHECK_FLT( RT_NOCRT(cosf)( +25.25252525252525f), +0.992834448814392f);
|
---|
3580 | CHECK_FLT( RT_NOCRT(cosf)( +252.25252525252525f), +0.601750433444977f);
|
---|
3581 | CHECK_FLT( RT_NOCRT(cosf)( +2525.25252525252525f), +0.832022845745087f);
|
---|
3582 | CHECK_FLT( RT_NOCRT(cosf)( +25252.25252525252525f), +0.991535484790802f);
|
---|
3583 | CHECK_FLT( RT_NOCRT(cosf)( +252525.25252525252525f), -0.628703236579895f);
|
---|
3584 | CHECK_FLT( RT_NOCRT(cosf)( +3.14f), -0.999998748302460f);
|
---|
3585 | CHECK_FLT( RT_NOCRT(cosf)( -1.0f), +0.540302276611328f);
|
---|
3586 | CHECK_FLT( RT_NOCRT(cosf)( -2.0f), -0.416146844625473f);
|
---|
3587 | CHECK_FLT( RT_NOCRT(cosf)( -3.0f), -0.989992499351501f);
|
---|
3588 | CHECK_FLT( RT_NOCRT(cosf)( -4.0f), -0.653643608093262f);
|
---|
3589 | CHECK_FLT( RT_NOCRT(cosf)( -5.0f), +0.283662199974060f);
|
---|
3590 | CHECK_FLT( RT_NOCRT(cosf)( -6.0f), +0.960170269012451f);
|
---|
3591 | CHECK_FLT( RT_NOCRT(cosf)( -7.0f), +0.753902256488800f);
|
---|
3592 | CHECK_FLT( RT_NOCRT(cosf)( -8.0f), -0.145500034093857f);
|
---|
3593 | CHECK_FLT( RT_NOCRT(cosf)( -9.0f), -0.911130249500275f);
|
---|
3594 | CHECK_FLT( RT_NOCRT(cosf)( -10.0f), -0.839071512222290f);
|
---|
3595 | CHECK_FLT( RT_NOCRT(cosf)( -100.0f), +0.862318873405457f);
|
---|
3596 | CHECK_FLT( RT_NOCRT(cosf)( -654.216812456f), +0.721018731594086f);
|
---|
3597 | CHECK_FLT( RT_NOCRT(cosf)( -10.10101010101010f), -0.779936254024506f);
|
---|
3598 | CHECK_FLT( RT_NOCRT(cosf)( -25.25252525252525f), +0.992834448814392f);
|
---|
3599 | CHECK_FLT( RT_NOCRT(cosf)( -252.25252525252525f), +0.601750433444977f);
|
---|
3600 | CHECK_FLT( RT_NOCRT(cosf)( -2525.25252525252525f), +0.832022845745087f);
|
---|
3601 | CHECK_FLT( RT_NOCRT(cosf)( -25252.25252525252525f), +0.991535484790802f);
|
---|
3602 | CHECK_FLT( RT_NOCRT(cosf)( -252525.25252525252525f), -0.628703236579895f);
|
---|
3603 | CHECK_FLT( RT_NOCRT(cosf)( -3.14f), -0.999998748302460f);
|
---|
3604 | CHECK_FLT( RT_NOCRT(cosf)( RTStrNanFloat("123s", false)), RTStrNanFloat("123s", false));
|
---|
3605 | CHECK_FLT( RT_NOCRT(cosf)( RTStrNanFloat("9991s", true)), RTStrNanFloat("9991s", true));
|
---|
3606 |
|
---|
3607 | CHECK_FLT_SAME( cos,( 1.0f));
|
---|
3608 | CHECK_FLT_SAME( cos,( 1.5f));
|
---|
3609 | CHECK_FLT_SAME( cos,( +0.0f));
|
---|
3610 | CHECK_FLT_SAME( cos,( +0.0f));
|
---|
3611 | CHECK_FLT_SAME( cos,( -0.0f));
|
---|
3612 | CHECK_FLT_SAME( cos,( -0.0f));
|
---|
3613 | CHECK_FLT_SAME( cos,( 238.6634566f));
|
---|
3614 | CHECK_FLT_SAME( cos,( -49.4578999f));
|
---|
3615 | CHECK_FLT_SAME( cos,( +(float)M_PI));
|
---|
3616 | CHECK_FLT_SAME( cos,( -(float)M_PI));
|
---|
3617 | CHECK_FLT_SAME( cos,( +(float)M_PI_2));
|
---|
3618 | CHECK_FLT_SAME( cos,( -(float)M_PI_2));
|
---|
3619 | CHECK_FLT_SAME( cos,( +(float)INFINITY));
|
---|
3620 | CHECK_FLT_SAME( cos,( -(float)INFINITY));
|
---|
3621 | CHECK_FLT_SAME( cos,(RTStrNanFloat(NULL, false)));
|
---|
3622 | CHECK_FLT_SAME( cos,(RTStrNanFloat(NULL, true)));
|
---|
3623 | }
|
---|
3624 |
|
---|
3625 |
|
---|
3626 | void testTan()
|
---|
3627 | {
|
---|
3628 | RTTestSub(g_hTest, "tan[f]");
|
---|
3629 |
|
---|
3630 | /* See comment in testSin regarding testing and accuracy. Note that tan
|
---|
3631 | and tanf have receive no extra attention yet and are solely based on
|
---|
3632 | the FPU capabilities. */
|
---|
3633 | //lvbe /mnt/e/misc/float/tan -d +1.0 +2.0 +3.0 +4.0 +5.0 +6.0 +7.0 +8.0 +9.0 +10.0 +100.0 +654.216812456 +10.10101010101010 +25.25252525252525 +252.25252525252525 +2525.25252525252525 +25252.25252525252525 +252525.25252525252525 +3.14 +1.57 +2.355 +1.1775
|
---|
3634 | CHECK_DBL( RT_NOCRT(tan)( +0.0), +0.0);
|
---|
3635 | CHECK_DBL( RT_NOCRT(tan)( -0.0), -0.0);
|
---|
3636 | CHECK_DBL( tan( -0.0), -0.0);
|
---|
3637 | CHECK_DBL_RANGE(RT_NOCRT(tan)( +M_PI), +0.0, 0.0000000000000100000);
|
---|
3638 | CHECK_DBL_RANGE(RT_NOCRT(tan)( -M_PI), +0.0, 0.0000000000000100000);
|
---|
3639 | CHECK_DBL( RT_NOCRT(tan)( +1.0), +1.55740772465490229237);
|
---|
3640 | CHECK_DBL( RT_NOCRT(tan)( +2.0), -2.18503986326151888875);
|
---|
3641 | CHECK_DBL( RT_NOCRT(tan)( +3.0), -0.14254654307427780391);
|
---|
3642 | CHECK_DBL( RT_NOCRT(tan)( +4.0), +1.15782128234957748525);
|
---|
3643 | CHECK_DBL( RT_NOCRT(tan)( +5.0), -3.38051500624658585181);
|
---|
3644 | CHECK_DBL( RT_NOCRT(tan)( +6.0), -0.29100619138474914660);
|
---|
3645 | CHECK_DBL( RT_NOCRT(tan)( +7.0), +0.87144798272431878150);
|
---|
3646 | CHECK_DBL( RT_NOCRT(tan)( +8.0), -6.79971145522037900832);
|
---|
3647 | CHECK_DBL( RT_NOCRT(tan)( +9.0), -0.45231565944180984751);
|
---|
3648 | CHECK_DBL( RT_NOCRT(tan)( +10.0), +0.64836082745908663050);
|
---|
3649 | CHECK_DBL( RT_NOCRT(tan)( +100.0), -0.58721391515692911156);
|
---|
3650 | CHECK_DBL( RT_NOCRT(tan)( +654.216812456), +0.96105296910208881656);
|
---|
3651 | CHECK_DBL( RT_NOCRT(tan)( +10.10101010101010), +0.80244848750680519700);
|
---|
3652 | CHECK_DBL( RT_NOCRT(tan)( +25.25252525252525), +0.12036022656173953060);
|
---|
3653 | CHECK_DBL( RT_NOCRT(tan)( +252.25252525252525), +1.32728909752762014307);
|
---|
3654 | CHECK_DBL( RT_NOCRT(tan)( +2525.25252525252525), -0.66661702242341180913);
|
---|
3655 | CHECK_DBL_RANGE(RT_NOCRT(tan)( +25252.25252525252525), +0.13152635436679746550, 0.0000000000000010000);
|
---|
3656 | CHECK_DBL_RANGE(RT_NOCRT(tan)( +252525.25252525252525), +1.24331239382105529501, 0.0000000000000100000);
|
---|
3657 | CHECK_DBL( RT_NOCRT(tan)( +3.14), -0.00159265493640722302);
|
---|
3658 | CHECK_DBL( RT_NOCRT(tan)( +1.57), +1255.76559150078969651076);
|
---|
3659 | CHECK_DBL( RT_NOCRT(tan)( +2.355), -1.00239183854994351464);
|
---|
3660 | CHECK_DBL( RT_NOCRT(tan)( +1.1775), +2.41014118913622787943);
|
---|
3661 |
|
---|
3662 | CHECK_DBL( RT_NOCRT(tan)( -1.0), -1.55740772465490229237);
|
---|
3663 | CHECK_DBL( RT_NOCRT(tan)( -2.0), +2.18503986326151888875);
|
---|
3664 | CHECK_DBL( RT_NOCRT(tan)( -3.0), +0.14254654307427780391);
|
---|
3665 | CHECK_DBL( RT_NOCRT(tan)( -4.0), -1.15782128234957748525);
|
---|
3666 | CHECK_DBL( RT_NOCRT(tan)( -5.0), +3.38051500624658585181);
|
---|
3667 | CHECK_DBL( RT_NOCRT(tan)( -6.0), +0.29100619138474914660);
|
---|
3668 | CHECK_DBL( RT_NOCRT(tan)( -7.0), -0.87144798272431878150);
|
---|
3669 | CHECK_DBL( RT_NOCRT(tan)( -8.0), +6.79971145522037900832);
|
---|
3670 | CHECK_DBL( RT_NOCRT(tan)( -9.0), +0.45231565944180984751);
|
---|
3671 | CHECK_DBL( RT_NOCRT(tan)( -10.0), -0.64836082745908663050);
|
---|
3672 | CHECK_DBL( RT_NOCRT(tan)( -100.0), +0.58721391515692911156);
|
---|
3673 | CHECK_DBL( RT_NOCRT(tan)( -654.216812456), -0.96105296910208881656);
|
---|
3674 | CHECK_DBL( RT_NOCRT(tan)( -10.10101010101010), -0.80244848750680519700);
|
---|
3675 | CHECK_DBL( RT_NOCRT(tan)( -25.25252525252525), -0.12036022656173953060);
|
---|
3676 | CHECK_DBL( RT_NOCRT(tan)( -252.25252525252525), -1.32728909752762014307);
|
---|
3677 | CHECK_DBL( RT_NOCRT(tan)( -2525.25252525252525), +0.66661702242341180913);
|
---|
3678 | CHECK_DBL_RANGE(RT_NOCRT(tan)( -25252.25252525252525), -0.13152635436679746550, 0.0000000000000010000);
|
---|
3679 | CHECK_DBL_RANGE(RT_NOCRT(tan)( -252525.25252525252525), -1.24331239382105529501, 0.0000000000000100000);
|
---|
3680 | CHECK_DBL( RT_NOCRT(tan)( -3.14), +0.00159265493640722302);
|
---|
3681 | CHECK_DBL( RT_NOCRT(tan)( RTStrNanDouble(NULL, true)), RTStrNanDouble(NULL, true));
|
---|
3682 | CHECK_DBL( RT_NOCRT(tan)( RTStrNanDouble("4940", false)), RTStrNanDouble("4940", false));
|
---|
3683 | //CHECK_DBL( RT_NOCRT(tan)( RTStrNanDouble("494s", false)), RTStrNanDouble("494s", false)); //- not preserved
|
---|
3684 | CHECK_DBL_SAME(tan,( +0.0));
|
---|
3685 | CHECK_DBL_SAME(tan,( -0.0));
|
---|
3686 | CHECK_DBL_SAME(tan,( +1.0));
|
---|
3687 | CHECK_DBL_SAME(tan,( -1.0));
|
---|
3688 | #if 0 /* the FPU reduction isn't accurate enough, don't want to spend time on this now. */
|
---|
3689 | CHECK_DBL_SAME(tan,( +M_PI));
|
---|
3690 | CHECK_DBL_SAME(tan,( -M_PI));
|
---|
3691 | #endif
|
---|
3692 | CHECK_DBL_SAME(tan,( -6.0));
|
---|
3693 | CHECK_DBL_SAME(tan,( -6.333));
|
---|
3694 | CHECK_DBL_SAME(tan,( +6.666));
|
---|
3695 | CHECK_DBL_SAME(tan,( 246.36775));
|
---|
3696 | CHECK_DBL_SAME(tan,( +INFINITY));
|
---|
3697 | CHECK_DBL_SAME(tan,( -INFINITY));
|
---|
3698 | CHECK_DBL_SAME(tan,(RTStrNanDouble(NULL, true)));
|
---|
3699 | CHECK_DBL_SAME(tan,(RTStrNanDouble("s", true)));
|
---|
3700 |
|
---|
3701 |
|
---|
3702 | //lvbe /mnt/e/misc/float/tan -f +1.0 +2.0 +3.0 +4.0 +5.0 +6.0 +7.0 +8.0 +9.0 +10.0 +100.0 +654.216812456 +10.10101010101010 +25.25252525252525 +252.25252525252525 +2525.25252525252525 +25252.25252525252525 +252525.25252525252525 +3.14 +1.57 +2.355 +1.1775
|
---|
3703 | //lvbe /mnt/e/misc/float/tan -f -1.0 -2.0 -3.0 -4.0 -5.0 -6.0 -7.0 -8.0 -9.0 -10.0 -100.0 -654.216812456 -10.10101010101010 -25.25252525252525 -252.25252525252525 -2525.25252525252525 -25252.25252525252525 -252525.25252525252525 -3.14 -1.57 -2.355 -1.1775
|
---|
3704 | CHECK_FLT( RT_NOCRT(tanf)( +0.0f), +0.0f);
|
---|
3705 | CHECK_FLT( RT_NOCRT(tanf)( -0.0f), -0.0f);
|
---|
3706 | CHECK_FLT_RANGE(RT_NOCRT(tanf)( +(float)M_PI), +0.0f, 0.000000100000000f);
|
---|
3707 | CHECK_FLT_RANGE(RT_NOCRT(tanf)( -(float)M_PI), +0.0f, 0.000000100000000f);
|
---|
3708 | CHECK_FLT( RT_NOCRT(tanf)( +1.0f), +1.557407736778259f);
|
---|
3709 | CHECK_FLT( RT_NOCRT(tanf)( +2.0f), -2.185039758682251f);
|
---|
3710 | CHECK_FLT( RT_NOCRT(tanf)( +3.0f), -0.142546549439430f);
|
---|
3711 | CHECK_FLT( RT_NOCRT(tanf)( +4.0f), +1.157821297645569f);
|
---|
3712 | CHECK_FLT( RT_NOCRT(tanf)( +5.0f), -3.380515098571777f);
|
---|
3713 | CHECK_FLT( RT_NOCRT(tanf)( +6.0f), -0.291006177663803f);
|
---|
3714 | CHECK_FLT( RT_NOCRT(tanf)( +7.0f), +0.871447980403900f);
|
---|
3715 | CHECK_FLT( RT_NOCRT(tanf)( +8.0f), -6.799711227416992f);
|
---|
3716 | CHECK_FLT( RT_NOCRT(tanf)( +9.0f), -0.452315658330917f);
|
---|
3717 | CHECK_FLT( RT_NOCRT(tanf)( +10.0f), +0.648360848426819f);
|
---|
3718 | CHECK_FLT( RT_NOCRT(tanf)( +100.0f), -0.587213933467865f);
|
---|
3719 | CHECK_FLT( RT_NOCRT(tanf)( +654.216812456f), +0.961022973060608f);
|
---|
3720 | CHECK_FLT( RT_NOCRT(tanf)( +10.10101010101010f), +0.802448868751526f);
|
---|
3721 | CHECK_FLT( RT_NOCRT(tanf)( +25.25252525252525f), +0.120360307395458f);
|
---|
3722 | CHECK_FLT( RT_NOCRT(tanf)( +252.25252525252525f), +1.327268242835999f);
|
---|
3723 | CHECK_FLT( RT_NOCRT(tanf)( +2525.25252525252525f), -0.666738152503967f);
|
---|
3724 | CHECK_FLT( RT_NOCRT(tanf)( +25252.25252525252525f), +0.130944371223450f);
|
---|
3725 | CHECK_FLT( RT_NOCRT(tanf)( +252525.25252525252525f), +1.236903667449951f);
|
---|
3726 | CHECK_FLT( RT_NOCRT(tanf)( +3.14f), -0.001592550077476f);
|
---|
3727 | CHECK_FLT( RT_NOCRT(tanf)( +1.57f), +1255.848266601562500f);
|
---|
3728 | CHECK_FLT( RT_NOCRT(tanf)( +2.355f), -1.002391815185547f);
|
---|
3729 | CHECK_FLT( RT_NOCRT(tanf)( +1.1775f), +2.410141229629517f);
|
---|
3730 | CHECK_FLT( RT_NOCRT(tanf)( -1.0f), -1.557407736778259f);
|
---|
3731 | CHECK_FLT( RT_NOCRT(tanf)( -2.0f), +2.185039758682251f);
|
---|
3732 | CHECK_FLT( RT_NOCRT(tanf)( -3.0f), +0.142546549439430f);
|
---|
3733 | CHECK_FLT( RT_NOCRT(tanf)( -4.0f), -1.157821297645569f);
|
---|
3734 | CHECK_FLT( RT_NOCRT(tanf)( -5.0f), +3.380515098571777f);
|
---|
3735 | CHECK_FLT( RT_NOCRT(tanf)( -6.0f), +0.291006177663803f);
|
---|
3736 | CHECK_FLT( RT_NOCRT(tanf)( -7.0f), -0.871447980403900f);
|
---|
3737 | CHECK_FLT( RT_NOCRT(tanf)( -8.0f), +6.799711227416992f);
|
---|
3738 | CHECK_FLT( RT_NOCRT(tanf)( -9.0f), +0.452315658330917f);
|
---|
3739 | CHECK_FLT( RT_NOCRT(tanf)( -10.0f), -0.648360848426819f);
|
---|
3740 | CHECK_FLT( RT_NOCRT(tanf)( -100.0f), +0.587213933467865f);
|
---|
3741 | CHECK_FLT( RT_NOCRT(tanf)( -654.216812456f), -0.961022973060608f);
|
---|
3742 | CHECK_FLT( RT_NOCRT(tanf)( -10.10101010101010f), -0.802448868751526f);
|
---|
3743 | CHECK_FLT( RT_NOCRT(tanf)( -25.25252525252525f), -0.120360307395458f);
|
---|
3744 | CHECK_FLT( RT_NOCRT(tanf)( -252.25252525252525f), -1.327268242835999f);
|
---|
3745 | CHECK_FLT( RT_NOCRT(tanf)( -2525.25252525252525f), +0.666738152503967f);
|
---|
3746 | CHECK_FLT( RT_NOCRT(tanf)( -25252.25252525252525f), -0.130944371223450f);
|
---|
3747 | CHECK_FLT( RT_NOCRT(tanf)( -252525.25252525252525f), -1.236903667449951f);
|
---|
3748 | CHECK_FLT( RT_NOCRT(tanf)( -3.14f), +0.001592550077476f);
|
---|
3749 | CHECK_FLT( RT_NOCRT(tanf)( -1.57f), -1255.848266601562500f);
|
---|
3750 | CHECK_FLT( RT_NOCRT(tanf)( -2.355f), +1.002391815185547f);
|
---|
3751 | CHECK_FLT( RT_NOCRT(tanf)( -1.1775f), -2.410141229629517f);
|
---|
3752 | CHECK_FLT( RT_NOCRT(tanf)( RTStrNanFloat(NULL, true)), RTStrNanFloat(NULL, true));
|
---|
3753 | CHECK_FLT( RT_NOCRT(tanf)( RTStrNanFloat("4940", false)), RTStrNanFloat("4940", false));
|
---|
3754 | //CHECK_FLT( RT_NOCRT(tanf)( RTStrNanFloat("494s", false)), RTStrNanFloat("494s", false)); - not preserved
|
---|
3755 |
|
---|
3756 | CHECK_FLT_SAME(tanf,( +0.0f));
|
---|
3757 | CHECK_FLT_SAME(tanf,( -0.0f));
|
---|
3758 | CHECK_FLT_SAME(tanf,( +1.0f));
|
---|
3759 | CHECK_FLT_SAME(tanf,( -1.0f));
|
---|
3760 | CHECK_FLT_SAME(tanf,( -6.0f));
|
---|
3761 | CHECK_FLT_SAME(tanf,( -6.333f));
|
---|
3762 | CHECK_FLT_SAME(tanf,( +6.666f));
|
---|
3763 | CHECK_FLT_SAME(tanf,( 246.36775f));
|
---|
3764 |
|
---|
3765 | CHECK_FLT_SAME(tanf,( +(float)INFINITY));
|
---|
3766 | CHECK_FLT_SAME(tanf,( -(float)INFINITY));
|
---|
3767 | CHECK_FLT_SAME(tanf,(RTStrNanFloat(NULL, true)));
|
---|
3768 | CHECK_FLT_SAME(tanf,(RTStrNanFloat("s", true)));
|
---|
3769 | }
|
---|
3770 |
|
---|
3771 |
|
---|
3772 | int main()
|
---|
3773 | {
|
---|
3774 | RTEXITCODE rcExit = RTTestInitAndCreate("tstRTNoCrt-2", &g_hTest);
|
---|
3775 | if (rcExit != RTEXITCODE_SUCCESS)
|
---|
3776 | return rcExit;
|
---|
3777 |
|
---|
3778 | /* Some preconditions: */
|
---|
3779 | RTFLOAT32U r32;
|
---|
3780 | r32.r = RTStrNanFloat("s", false);
|
---|
3781 | RTTEST_CHECK(g_hTest, RTFLOAT32U_IS_SIGNALLING_NAN(&r32));
|
---|
3782 | r32.r = RTStrNanFloat("q", false);
|
---|
3783 | RTTEST_CHECK(g_hTest, RTFLOAT32U_IS_QUIET_NAN(&r32));
|
---|
3784 | r32.r = RTStrNanFloat(NULL, false);
|
---|
3785 | RTTEST_CHECK(g_hTest, RTFLOAT32U_IS_QUIET_NAN(&r32));
|
---|
3786 |
|
---|
3787 | RTFLOAT64U r64;
|
---|
3788 | r64.r = RTStrNanDouble("s", false);
|
---|
3789 | RTTEST_CHECK(g_hTest, RTFLOAT64U_IS_SIGNALLING_NAN(&r64));
|
---|
3790 | r64.r = RTStrNanDouble("q", false);
|
---|
3791 | RTTEST_CHECK(g_hTest, RTFLOAT64U_IS_QUIET_NAN(&r64));
|
---|
3792 | r64.r = RTStrNanDouble(NULL, false);
|
---|
3793 | RTTEST_CHECK(g_hTest, RTFLOAT64U_IS_QUIET_NAN(&r64));
|
---|
3794 |
|
---|
3795 | /* stdlib.h (integer) */
|
---|
3796 | testAbs();
|
---|
3797 |
|
---|
3798 | /* math.h */
|
---|
3799 | testFAbs();
|
---|
3800 | testCopySign();
|
---|
3801 | testFmax();
|
---|
3802 | testFmin();
|
---|
3803 | testIsInf();
|
---|
3804 | testIsNan();
|
---|
3805 | testIsFinite();
|
---|
3806 | testIsNormal();
|
---|
3807 | testFpClassify();
|
---|
3808 | testSignBit();
|
---|
3809 | testFrExp();
|
---|
3810 | testCeil();
|
---|
3811 | testFloor();
|
---|
3812 | testTrunc();
|
---|
3813 | testRound();
|
---|
3814 | testRInt();
|
---|
3815 | testLRound();
|
---|
3816 | testLLRound();
|
---|
3817 | testLRInt();
|
---|
3818 | testLLRInt();
|
---|
3819 |
|
---|
3820 | testExp();
|
---|
3821 | testExp2();
|
---|
3822 | testLdExp();
|
---|
3823 | testPow();
|
---|
3824 | testFma();
|
---|
3825 | testRemainder();
|
---|
3826 | testLog();
|
---|
3827 | testLog2();
|
---|
3828 | testSqRt();
|
---|
3829 |
|
---|
3830 | testATan();
|
---|
3831 | testATan2();
|
---|
3832 | testSin();
|
---|
3833 | testCos();
|
---|
3834 | testTan();
|
---|
3835 |
|
---|
3836 | return RTTestSummaryAndDestroy(g_hTest);
|
---|
3837 | }
|
---|
3838 |
|
---|