VirtualBox

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

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

IPRT/nocrt: Implemented exp. bugref:10261

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