VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstRTNoCrt-2.cpp@ 102335

Last change on this file since 102335 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette