VirtualBox

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

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

IPRT/tstRTNoCrt-2: atan[f] tests. bugref:10261

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 139.9 KB
Line 
1/* $Id: tstRTNoCrt-2.cpp 96224 2022-08-15 14:19:05Z 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
54/*********************************************************************************************************************************
55* Defined Constants And Macros *
56*********************************************************************************************************************************/
57/*
58 * Macros checking i n t e g e r returns.
59 */
60#define CHECK_INT(a_Expr, a_rcExpect) do { \
61 int const rcActual = (a_Expr); \
62 if (rcActual != (a_rcExpect)) \
63 RTTestFailed(g_hTest, "line %u: %s -> %d, expected %d", __LINE__, #a_Expr, rcActual, (a_rcExpect)); \
64 } while (0)
65
66#define CHECK_INT_SAME(a_Fn, a_Args) do { \
67 int const rcNoCrt = RT_NOCRT(a_Fn) a_Args; \
68 int const rcCrt = a_Fn a_Args; \
69 if (rcNoCrt != rcCrt) \
70 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %d; CRT => %d", __LINE__, #a_Fn, #a_Args, rcNoCrt, rcCrt); \
71 } while (0)
72
73
74/*
75 * Macros checking l o n g returns.
76 */
77#define CHECK_LONG(a_Expr, a_rcExpect) do { \
78 long const rcActual = (a_Expr); \
79 long const rcExpect = (a_rcExpect); \
80 if (rcActual != rcExpect) \
81 RTTestFailed(g_hTest, "line %u: %s -> %ld, expected %ld", __LINE__, #a_Expr, rcActual, rcExpect); \
82 } while (0)
83
84#define CHECK_LONG_SAME(a_Fn, a_Args) do { \
85 long const rcNoCrt = RT_NOCRT(a_Fn) a_Args; \
86 long const rcCrt = a_Fn a_Args; \
87 if (rcNoCrt != rcCrt) \
88 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %ld; CRT => %ld", __LINE__, #a_Fn, #a_Args, rcNoCrt, rcCrt); \
89 } while (0)
90
91
92/*
93 * Macros checking l o n g l o n g returns.
94 */
95#define CHECK_LLONG(a_Expr, a_rcExpect) do { \
96 long long const rcActual = (a_Expr); \
97 long long const rcExpect = (a_rcExpect); \
98 if (rcActual != rcExpect) \
99 RTTestFailed(g_hTest, "line %u: %s -> %lld, expected %lld", __LINE__, #a_Expr, rcActual, rcExpect); \
100 } while (0)
101
102#define CHECK_LLONG_SAME(a_Fn, a_Args) do { \
103 long long const rcNoCrt = RT_NOCRT(a_Fn) a_Args; \
104 long long const rcCrt = a_Fn a_Args; \
105 if (rcNoCrt != rcCrt) \
106 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %lld; CRT => %lld", __LINE__, #a_Fn, #a_Args, rcNoCrt, rcCrt); \
107 } while (0)
108
109
110/*
111 * Macros checking l o n g d o u b l e returns.
112 */
113#ifdef RT_COMPILER_WITH_80BIT_LONG_DOUBLE
114# define CHECK_LDBL(a_Expr, a_lrdExpect) do { \
115 RTFLOAT80U2 uRet; \
116 uRet.r = (a_Expr); \
117 RTFLOAT80U2 uExpect; \
118 uExpect.r = a_lrdExpect; \
119 if (!RTFLOAT80U_ARE_IDENTICAL(&uRet, &uExpect)) \
120 { \
121 RTStrFormatR80u2(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
122 RTStrFormatR80u2(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
123 RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
124 __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_lrdExpect); \
125 } \
126 } while (0)
127
128# define CHECK_LDBL_SAME(a_Fn, a_Args) do { \
129 RTFLOAT80U2 uNoCrtRet, uCrtRet; \
130 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
131 uCrtRet.r = a_Fn a_Args; \
132 if (!RTFLOAT80U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
133 { \
134 RTStrFormatR80u2(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
135 RTStrFormatR80u2(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
136 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
137 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
138 } \
139 } while (0)
140
141# define CHECK_LDBL_APPROX_SAME(a_Fn, a_Args) do { \
142 RTFLOAT80U2 uNoCrtRet, uCrtRet; \
143 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
144 uCrtRet.r = a_Fn a_Args; \
145 if ( !RTFLOAT80U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
146 && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
147 || RTFLOAT80U_IS_NAN(&uNoCrtRet) \
148 || RTFLOAT80U_IS_NAN(&uCrtRet) ) ) \
149 { \
150 RTStrFormatR80u2(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
151 RTStrFormatR80u2(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
152 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
153 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
154 } \
155 } while (0)
156
157# define CHECK_LDBL_SAME_RELAXED_NAN(a_Fn, a_Args) do { \
158 RTFLOAT80U2 uNoCrtRet, uCrtRet; \
159 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
160 uCrtRet.r = a_Fn a_Args; \
161 if ( !RTFLOAT80U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
162 && ( !RTFLOAT80U_IS_NAN(&uNoCrtRet) \
163 || !RTFLOAT80U_IS_NAN(&uCrtRet) ) ) \
164 { \
165 RTStrFormatR80u2(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
166 RTStrFormatR80u2(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
167 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
168 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
169 } \
170 } while (0)
171
172#elif defined(RT_COMPILER_WITH_128BIT_LONG_DOUBLE)
173# error todo
174
175#else
176# define CHECK_LDBL(a_Expr, a_lrdExpect) do { \
177 RTFLOAT64U uRet; \
178 uRet.lrd = (a_Expr); \
179 RTFLOAT64U uExpect; \
180 uExpect.lrd = a_lrdExpect; \
181 if (!RTFLOAT64U_ARE_IDENTICAL(&uRet, &uExpect)) \
182 { \
183 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
184 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
185 RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
186 __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_lrdExpect); \
187 } \
188 } while (0)
189
190# define CHECK_LDBL_SAME(a_Fn, a_Args) do { \
191 RTFLOAT64U uNoCrtRet, uCrtRet; \
192 uNoCrtRet.lrd = RT_NOCRT(a_Fn) a_Args; \
193 uCrtRet.lrd = a_Fn a_Args; \
194 if (!RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
195 { \
196 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
197 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
198 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
199 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
200 } \
201 } while (0)
202
203# define CHECK_LDBL_APPROX_SAME(a_Fn, a_Args) do { \
204 RTFLOAT64U uNoCrtRet, uCrtRet; \
205 uNoCrtRet.lrd = RT_NOCRT(a_Fn) a_Args; \
206 uCrtRet.lrd = a_Fn a_Args; \
207 if ( !RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
208 && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
209 || RTFLOAT64U_IS_NAN(&uNoCrtRet) \
210 || RTFLOAT64U_IS_NAN(&uCrtRet) ) ) \
211 { \
212 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
213 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
214 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
215 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
216 } \
217 } while (0)
218
219# define CHECK_LDBL_SAME_RELAXED_NAN(a_Fn, a_Args) do { \
220 RTFLOAT64U uNoCrtRet, uCrtRet; \
221 uNoCrtRet.lrd = RT_NOCRT(a_Fn) a_Args; \
222 uCrtRet.lrd = a_Fn a_Args; \
223 if ( !RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
224 && ( !RTFLOAT64U_IS_NAN(&uNoCrtRet) \
225 || !RTFLOAT64U_IS_NAN(&uCrtRet) ) ) \
226 { \
227 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
228 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
229 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
230 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
231 } \
232 } while (0)
233#endif
234
235
236/*
237 * Macros checking d o u b l e returns.
238 */
239#define CHECK_DBL(a_Expr, a_rdExpect) do { \
240 RTFLOAT64U uRet; \
241 uRet.r = (a_Expr); \
242 RTFLOAT64U uExpect; \
243 uExpect.r = a_rdExpect; \
244 if (!RTFLOAT64U_ARE_IDENTICAL(&uRet, &uExpect)) \
245 { \
246 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
247 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
248 RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
249 __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_rdExpect); \
250 } \
251 } while (0)
252
253#define CHECK_DBL_SAME(a_Fn, a_Args) do { \
254 RTFLOAT64U uNoCrtRet, uCrtRet; \
255 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
256 uCrtRet.r = a_Fn a_Args; \
257 if (!RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
258 { \
259 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
260 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
261 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
262 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
263 } \
264 } while (0)
265
266#define CHECK_DBL_APPROX_SAME(a_Fn, a_Args) do { \
267 RTFLOAT64U uNoCrtRet, uCrtRet; \
268 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
269 uCrtRet.r = a_Fn a_Args; \
270 if ( !RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
271 && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
272 || RTFLOAT64U_IS_NAN(&uNoCrtRet) \
273 || RTFLOAT64U_IS_NAN(&uCrtRet) ) ) \
274 { \
275 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
276 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
277 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
278 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
279 } \
280 } while (0)
281
282#define CHECK_DBL_SAME_RELAXED_NAN(a_Fn, a_Args) do { \
283 RTFLOAT64U uNoCrtRet, uCrtRet; \
284 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
285 uCrtRet.r = a_Fn a_Args; \
286 if ( !RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
287 && ( !RTFLOAT64U_IS_NAN(&uNoCrtRet) \
288 || !RTFLOAT64U_IS_NAN(&uCrtRet) ) ) \
289 { \
290 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
291 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
292 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
293 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
294 } \
295 } while (0)
296
297/*
298 * Macros checking f l o a t returns.
299 */
300#define CHECK_FLT(a_Expr, a_rExpect) do { \
301 RTFLOAT32U uRet; \
302 uRet.r = (a_Expr); \
303 RTFLOAT32U uExpect; \
304 uExpect.r = a_rExpect; \
305 if (!RTFLOAT32U_ARE_IDENTICAL(&uRet, &uExpect)) \
306 { \
307 RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
308 RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
309 RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
310 __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_rExpect); \
311 } \
312 } while (0)
313
314#define CHECK_FLT_SAME(a_Fn, a_Args) do { \
315 RTFLOAT32U uNoCrtRet, uCrtRet; \
316 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
317 uCrtRet.r = a_Fn a_Args; \
318 if (!RTFLOAT32U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
319 { \
320 RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
321 RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
322 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
323 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
324 } \
325 } while (0)
326
327#define CHECK_FLT_APPROX_SAME(a_Fn, a_Args) do { \
328 RTFLOAT32U uNoCrtRet, uCrtRet; \
329 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
330 uCrtRet.r = a_Fn a_Args; \
331 if ( !RTFLOAT32U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
332 && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
333 || RTFLOAT32U_IS_NAN(&uNoCrtRet) \
334 || RTFLOAT32U_IS_NAN(&uCrtRet) ) ) \
335 { \
336 RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
337 RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
338 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
339 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
340 } \
341 } while (0)
342
343#define CHECK_FLT_SAME_RELAXED_NAN(a_Fn, a_Args) do { \
344 RTFLOAT32U uNoCrtRet, uCrtRet; \
345 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
346 uCrtRet.r = a_Fn a_Args; \
347 if ( !RTFLOAT32U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
348 && ( !RTFLOAT32U_IS_NAN(&uNoCrtRet) \
349 || !RTFLOAT32U_IS_NAN(&uCrtRet) ) ) \
350 { \
351 RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
352 RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
353 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
354 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
355 } \
356 } while (0)
357
358
359/*********************************************************************************************************************************
360* Global Variables *
361*********************************************************************************************************************************/
362RTTEST g_hTest;
363char g_szFloat[2][128];
364
365
366#ifdef _MSC_VER
367# pragma fenv_access(on)
368#endif
369
370
371void testAbs()
372{
373 RTTestSub(g_hTest, "abs,labs,llabs");
374 CHECK_INT(RT_NOCRT(abs)(1), 1);
375 CHECK_INT(RT_NOCRT(abs)(-1), 1);
376 CHECK_INT(RT_NOCRT(abs)(9685), 9685);
377 CHECK_INT(RT_NOCRT(abs)(-9685), 9685);
378 CHECK_INT(RT_NOCRT(abs)(589685), 589685);
379 CHECK_INT(RT_NOCRT(abs)(-589685), 589685);
380 CHECK_INT(RT_NOCRT(abs)(INT_MAX), INT_MAX);
381 CHECK_INT(RT_NOCRT(abs)(INT_MIN + 1), INT_MAX);
382 CHECK_INT(RT_NOCRT(abs)(INT_MIN), INT_MIN); /* oddity */
383 CHECK_INT_SAME(abs,(INT_MIN));
384 CHECK_INT_SAME(abs,(INT_MAX));
385
386 CHECK_LONG(RT_NOCRT(labs)(1), 1);
387 CHECK_LONG(RT_NOCRT(labs)(-1), 1);
388 CHECK_LONG(RT_NOCRT(labs)(9685), 9685);
389 CHECK_LONG(RT_NOCRT(labs)(-9685), 9685);
390 CHECK_LONG(RT_NOCRT(labs)(589685), 589685);
391 CHECK_LONG(RT_NOCRT(labs)(-589685), 589685);
392 CHECK_LONG(RT_NOCRT(labs)(LONG_MAX), LONG_MAX);
393 CHECK_LONG(RT_NOCRT(labs)(LONG_MIN + 1), LONG_MAX);
394 CHECK_LONG(RT_NOCRT(labs)(LONG_MIN), LONG_MIN); /* oddity */
395 CHECK_LONG_SAME(labs,(LONG_MIN));
396 CHECK_LONG_SAME(labs,(LONG_MAX));
397
398 CHECK_LONG(RT_NOCRT(llabs)(1), 1);
399 CHECK_LONG(RT_NOCRT(llabs)(-1), 1);
400 CHECK_LONG(RT_NOCRT(llabs)(9685), 9685);
401 CHECK_LONG(RT_NOCRT(llabs)(-9685), 9685);
402 CHECK_LONG(RT_NOCRT(llabs)(589685), 589685);
403 CHECK_LONG(RT_NOCRT(llabs)(-589685), 589685);
404 CHECK_LONG(RT_NOCRT(llabs)(LONG_MAX), LONG_MAX);
405 CHECK_LONG(RT_NOCRT(llabs)(LONG_MIN + 1), LONG_MAX);
406 CHECK_LONG(RT_NOCRT(llabs)(LONG_MIN), LONG_MIN); /* oddity */
407 CHECK_LONG_SAME(llabs,(LONG_MIN));
408 CHECK_LONG_SAME(llabs,(LONG_MAX));
409}
410
411
412void testFAbs()
413{
414 RTTestSub(g_hTest, "fabs[fl]");
415
416 CHECK_DBL(RT_NOCRT(fabs)( +0.0), +0.0);
417 CHECK_DBL(RT_NOCRT(fabs)( -0.0), +0.0);
418 CHECK_DBL(RT_NOCRT(fabs)( -42.5), +42.5);
419 CHECK_DBL(RT_NOCRT(fabs)( +42.5), +42.5);
420 CHECK_DBL(RT_NOCRT(fabs)(+1234.60958634e+20), +1234.60958634e+20);
421 CHECK_DBL(RT_NOCRT(fabs)(-1234.60958634e+20), +1234.60958634e+20);
422 CHECK_DBL(RT_NOCRT(fabs)( +2.1984e-310), +2.1984e-310); /* subnormal */
423 CHECK_DBL(RT_NOCRT(fabs)( -2.1984e-310), +2.1984e-310); /* subnormal */
424 CHECK_DBL(RT_NOCRT(fabs)(-INFINITY), +INFINITY);
425 CHECK_DBL(RT_NOCRT(fabs)(+INFINITY), +INFINITY);
426 CHECK_DBL(RT_NOCRT(fabs)(RTStrNanDouble(NULL, true)), RTStrNanDouble(NULL, true));
427 CHECK_DBL(RT_NOCRT(fabs)(RTStrNanDouble("s", false)), RTStrNanDouble("s", true));
428 CHECK_DBL_SAME(fabs,( -0.0));
429 CHECK_DBL_SAME(fabs,( +0.0));
430 CHECK_DBL_SAME(fabs,( +22.5));
431 CHECK_DBL_SAME(fabs,( -22.5));
432 CHECK_DBL_SAME(fabs,( +2.1984e-310)); /* subnormal */
433 CHECK_DBL_SAME(fabs,( -2.1984e-310)); /* subnormal */
434 CHECK_DBL_SAME(fabs,(+1234.60958634e+20));
435 CHECK_DBL_SAME(fabs,(-1234.60958634e+20));
436 CHECK_DBL_SAME(fabs,(-INFINITY));
437 CHECK_DBL_SAME(fabs,(+INFINITY));
438 CHECK_DBL_SAME(fabs,(RTStrNanDouble(NULL, true)));
439 CHECK_DBL_SAME(fabs,(RTStrNanDouble("s", false)));
440
441 CHECK_FLT(RT_NOCRT(fabsf)( +0.0f), +0.0f);
442 CHECK_FLT(RT_NOCRT(fabsf)( -0.0f), +0.0f);
443 CHECK_FLT(RT_NOCRT(fabsf)( -42.5f), +42.5f);
444 CHECK_FLT(RT_NOCRT(fabsf)( +42.5f), +42.5f);
445 CHECK_FLT(RT_NOCRT(fabsf)(+1234.60958634e+20f), +1234.60958634e+20f);
446 CHECK_FLT(RT_NOCRT(fabsf)(-1234.60958634e+20f), +1234.60958634e+20f);
447 CHECK_FLT(RT_NOCRT(fabsf)( +2.1984e-310f), +2.1984e-310f); /* subnormal */
448 CHECK_FLT(RT_NOCRT(fabsf)( -2.1984e-310f), +2.1984e-310f); /* subnormal */
449 CHECK_FLT(RT_NOCRT(fabsf)(-INFINITY), +INFINITY);
450 CHECK_FLT(RT_NOCRT(fabsf)(+INFINITY), +INFINITY);
451 CHECK_FLT(RT_NOCRT(fabsf)(RTStrNanFloat(NULL, true)), RTStrNanFloat(NULL, true));
452 CHECK_FLT(RT_NOCRT(fabsf)(RTStrNanFloat("s", false)), RTStrNanFloat("s", true));
453 CHECK_FLT_SAME(fabsf,( -0.0f));
454 CHECK_FLT_SAME(fabsf,( +0.0f));
455 CHECK_FLT_SAME(fabsf,( +22.5f));
456 CHECK_FLT_SAME(fabsf,( -22.5f));
457 CHECK_FLT_SAME(fabsf,( +2.1984e-310f)); /* subnormal */
458 CHECK_FLT_SAME(fabsf,( -2.1984e-310f)); /* subnormal */
459 CHECK_FLT_SAME(fabsf,(+1234.60958634e+20f));
460 CHECK_FLT_SAME(fabsf,(-1234.60958634e+20f));
461 CHECK_FLT_SAME(fabsf,(-INFINITY));
462 CHECK_FLT_SAME(fabsf,(+INFINITY));
463 CHECK_FLT_SAME(fabsf,(RTStrNanFloat(NULL, true)));
464#if 0 /* UCRT on windows converts this to a quiet NaN, so skip it. */
465 CHECK_FLT_SAME(fabsf,(RTStrNanFloat("s", false)));
466#endif
467}
468
469
470void testCopySign()
471{
472 RTTestSub(g_hTest, "copysign[fl]");
473
474 CHECK_DBL(RT_NOCRT(copysign)(1.0, 2.0), 1.0);
475 CHECK_DBL(RT_NOCRT(copysign)(-1.0, 2.0), 1.0);
476 CHECK_DBL(RT_NOCRT(copysign)(-1.0, -2.0), -1.0);
477 CHECK_DBL(RT_NOCRT(copysign)(1.0, -2.0), -1.0);
478 CHECK_DBL(RT_NOCRT(copysign)(42.24, -INFINITY), -42.24);
479 CHECK_DBL(RT_NOCRT(copysign)(-42.24, +INFINITY), +42.24);
480 CHECK_DBL(RT_NOCRT(copysign)(-999888777.666, RTStrNanDouble(NULL, true)), +999888777.666);
481 CHECK_DBL(RT_NOCRT(copysign)(-999888777.666, RTStrNanDouble("sig", true)), +999888777.666);
482 CHECK_DBL(RT_NOCRT(copysign)(+999888777.666, RTStrNanDouble(NULL, false)), -999888777.666);
483 CHECK_DBL_SAME(copysign,(1.0, 2.0));
484 CHECK_DBL_SAME(copysign,(-1.0, 2.0));
485 CHECK_DBL_SAME(copysign,(-1.0, -2.0));
486 CHECK_DBL_SAME(copysign,(1.0, -2.0));
487 CHECK_DBL_SAME(copysign,(42.24, -INFINITY));
488 CHECK_DBL_SAME(copysign,(-42.24, +INFINITY));
489 CHECK_DBL_SAME(copysign,(-999888777.666, RTStrNanDouble(NULL, true)));
490 CHECK_DBL_SAME(copysign,(+999888777.666, RTStrNanDouble(NULL, false)));
491 CHECK_DBL_SAME(copysign,(+999888777.666, RTStrNanDouble("sig", false)));
492
493 CHECK_FLT(RT_NOCRT(copysignf)(1.0f, 2.0f), 1.0f);
494 CHECK_FLT(RT_NOCRT(copysignf)(-1.0f, 2.0f), 1.0f);
495 CHECK_FLT(RT_NOCRT(copysignf)(-1.0f, -2.0f), -1.0f);
496 CHECK_FLT(RT_NOCRT(copysignf)(1.0f, -2.0f), -1.0f);
497 CHECK_FLT(RT_NOCRT(copysignf)(42.24f, -INFINITY), -42.24f);
498 CHECK_FLT(RT_NOCRT(copysignf)(-42.24f, +INFINITY), +42.24f);
499 CHECK_FLT(RT_NOCRT(copysignf)(-999888777.666f, RTStrNanFloat(NULL, true)), +999888777.666f);
500 CHECK_FLT(RT_NOCRT(copysignf)(+999888777.666f, RTStrNanFloat(NULL, false)), -999888777.666f);
501 CHECK_FLT_SAME(copysignf,(1.0f, 2.0f));
502 CHECK_FLT_SAME(copysignf,(-3.0f, 2.0f));
503 CHECK_FLT_SAME(copysignf,(-5.0e3f, -2.0f));
504 CHECK_FLT_SAME(copysignf,(6.0e-3f, -2.0f));
505 CHECK_FLT_SAME(copysignf,(434.24f, -INFINITY));
506 CHECK_FLT_SAME(copysignf,(-42.24f, +INFINITY));
507 CHECK_FLT_SAME(copysignf,(-39480.6e+33f, RTStrNanFloat(NULL, true)));
508 CHECK_FLT_SAME(copysignf,(+39480.6e-32f, RTStrNanFloat(NULL, false)));
509
510 CHECK_LDBL(RT_NOCRT(copysignl)(1.0L, 2.0L), 1.0L);
511 CHECK_LDBL(RT_NOCRT(copysignl)(-1.0L, 2.0L), 1.0L);
512 CHECK_LDBL(RT_NOCRT(copysignl)(-1.0L, -2.0L), -1.0L);
513 CHECK_LDBL(RT_NOCRT(copysignl)(1.0L, -2.0L), -1.0L);
514 CHECK_LDBL(RT_NOCRT(copysignl)(42.24L, -INFINITY), -42.24L);
515 CHECK_LDBL(RT_NOCRT(copysignl)(-42.24L, +INFINITY), +42.24L);
516 CHECK_LDBL(RT_NOCRT(copysignl)(-999888777.666L, RTStrNanLongDouble(NULL, true)), +999888777.666L);
517 CHECK_LDBL(RT_NOCRT(copysignl)(+999888777.666L, RTStrNanLongDouble("2343f_sig", false)), -999888777.666L);
518 CHECK_LDBL_SAME(copysignl,(1.0L, 2.0L));
519 CHECK_LDBL_SAME(copysignl,(-3.0L, 2.0L));
520 CHECK_LDBL_SAME(copysignl,(-5.0e3L, -2.0L));
521 CHECK_LDBL_SAME(copysignl,(6.0e-3L, -2.0L));
522 CHECK_LDBL_SAME(copysignl,(434.24L, -INFINITY));
523 CHECK_LDBL_SAME(copysignl,(-42.24L, +INFINITY));
524 CHECK_LDBL_SAME(copysignl,(-39480.6e+33L, RTStrNanLongDouble("8888_s", true)));
525 CHECK_LDBL_SAME(copysignl,(+39480.6e-32L, RTStrNanLongDouble(NULL, false)));
526}
527
528
529void testFmax()
530{
531 RTTestSub(g_hTest, "fmax[fl]");
532
533 CHECK_DBL(RT_NOCRT(fmax)( 1.0, 1.0), 1.0);
534 CHECK_DBL(RT_NOCRT(fmax)( 4.0, 2.0), 4.0);
535 CHECK_DBL(RT_NOCRT(fmax)( 2.0, 4.0), 4.0);
536 CHECK_DBL(RT_NOCRT(fmax)(-2.0, -4.0), -2.0);
537 CHECK_DBL(RT_NOCRT(fmax)(-2.0, -4.0e-10), -4.0e-10);
538 CHECK_DBL(RT_NOCRT(fmax)(+INFINITY, +INFINITY), +INFINITY);
539 CHECK_DBL(RT_NOCRT(fmax)(-INFINITY, -INFINITY), -INFINITY);
540 CHECK_DBL(RT_NOCRT(fmax)(+INFINITY, -INFINITY), +INFINITY);
541 CHECK_DBL(RT_NOCRT(fmax)(-INFINITY, +INFINITY), +INFINITY);
542 CHECK_DBL_SAME(fmax, ( 99.99, 99.87));
543 CHECK_DBL_SAME(fmax, ( -99.99, -99.87));
544 CHECK_DBL_SAME(fmax, (-987.453, 34599.87));
545 CHECK_DBL_SAME(fmax, (34599.87, -987.453));
546 CHECK_DBL_SAME(fmax, ( +0.0, -0.0));
547 CHECK_DBL_SAME(fmax, ( -0.0, +0.0));
548 CHECK_DBL_SAME(fmax, ( -0.0, -0.0));
549 CHECK_DBL_SAME(fmax, (+INFINITY, +INFINITY));
550 CHECK_DBL_SAME(fmax, (-INFINITY, -INFINITY));
551 CHECK_DBL_SAME(fmax, (+INFINITY, -INFINITY));
552 CHECK_DBL_SAME(fmax, (-INFINITY, +INFINITY));
553 CHECK_DBL_SAME(fmax, (RTStrNanDouble(NULL, true), -42.4242424242e222));
554 CHECK_DBL_SAME(fmax, (RTStrNanDouble(NULL, false), -42.4242424242e222));
555 CHECK_DBL_SAME(fmax, (-42.4242424242e-222, RTStrNanDouble(NULL, true)));
556 CHECK_DBL_SAME(fmax, (-42.4242424242e-222, RTStrNanDouble(NULL, false)));
557 CHECK_DBL_SAME(fmax, (RTStrNanDouble("2", false), RTStrNanDouble(NULL, false)));
558 CHECK_DBL_SAME(fmax, (RTStrNanDouble("3", true), RTStrNanDouble(NULL, false)));
559 CHECK_DBL_SAME(fmax, (RTStrNanDouble("4sig", true), RTStrNanDouble(NULL, false)));
560
561 CHECK_FLT(RT_NOCRT(fmaxf)( 1.0f, 1.0f), 1.0f);
562 CHECK_FLT(RT_NOCRT(fmaxf)( 4.0f, 2.0f), 4.0f);
563 CHECK_FLT(RT_NOCRT(fmaxf)( 2.0f, 4.0f), 4.0f);
564 CHECK_FLT(RT_NOCRT(fmaxf)(-2.0f, -4.0f), -2.0f);
565 CHECK_FLT(RT_NOCRT(fmaxf)(-2.0f, -4.0e-10f), -4.0e-10f);
566 CHECK_FLT(RT_NOCRT(fmaxf)(+INFINITY, +INFINITY), +INFINITY);
567 CHECK_FLT(RT_NOCRT(fmaxf)(-INFINITY, -INFINITY), -INFINITY);
568 CHECK_FLT(RT_NOCRT(fmaxf)(+INFINITY, -INFINITY), +INFINITY);
569 CHECK_FLT(RT_NOCRT(fmaxf)(-INFINITY, +INFINITY), +INFINITY);
570 CHECK_FLT_SAME(fmaxf, ( 99.99f, 99.87f));
571 CHECK_FLT_SAME(fmaxf, ( -99.99f, -99.87f));
572 CHECK_FLT_SAME(fmaxf, (-987.453f, 34599.87f));
573 CHECK_FLT_SAME(fmaxf, (34599.87f, -987.453f));
574 CHECK_FLT_SAME(fmaxf, ( +0.0f, -0.0f));
575 CHECK_FLT_SAME(fmaxf, ( -0.0f, +0.0f));
576 CHECK_FLT_SAME(fmaxf, ( -0.0f, -0.0f));
577 CHECK_FLT_SAME(fmaxf, (+INFINITY, +INFINITY));
578 CHECK_FLT_SAME(fmaxf, (-INFINITY, -INFINITY));
579 CHECK_FLT_SAME(fmaxf, (+INFINITY, -INFINITY));
580 CHECK_FLT_SAME(fmaxf, (-INFINITY, +INFINITY));
581 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat(NULL, true), -42.4242424242e22f));
582 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat(NULL, false), -42.4242424242e22f));
583 CHECK_FLT_SAME(fmaxf, (-42.42424242e-22f, RTStrNanFloat(NULL, true)));
584 CHECK_FLT_SAME(fmaxf, (-42.42424242e-22f, RTStrNanFloat(NULL, false)));
585 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat("2", false), RTStrNanFloat(NULL, false)));
586 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat("3", true), RTStrNanFloat(NULL, false)));
587 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat("4sig", true), RTStrNanFloat(NULL, false)));
588
589 CHECK_LDBL(RT_NOCRT(fmaxl)( 1.0L, 1.0L), 1.0L);
590 CHECK_LDBL(RT_NOCRT(fmaxl)( 4.0L, 2.0L), 4.0L);
591 CHECK_LDBL(RT_NOCRT(fmaxl)( 2.0L, 4.0L), 4.0L);
592 CHECK_LDBL(RT_NOCRT(fmaxl)(-2.0L, -4.0L), -2.0L);
593 CHECK_LDBL(RT_NOCRT(fmaxl)(-2.0L, -4.0e-10L), -4.0e-10L);
594 CHECK_LDBL(RT_NOCRT(fmaxl)(+INFINITY, +INFINITY), +INFINITY);
595 CHECK_LDBL(RT_NOCRT(fmaxl)(-INFINITY, -INFINITY), -INFINITY);
596 CHECK_LDBL(RT_NOCRT(fmaxl)(+INFINITY, -INFINITY), +INFINITY);
597 CHECK_LDBL(RT_NOCRT(fmaxl)(-INFINITY, +INFINITY), +INFINITY);
598 CHECK_LDBL_SAME(fmaxl, ( 99.99L, 99.87L));
599 CHECK_LDBL_SAME(fmaxl, ( -99.99L, -99.87L));
600 CHECK_LDBL_SAME(fmaxl, (-987.453L, 34599.87L));
601 CHECK_LDBL_SAME(fmaxl, (34599.87L, -987.453L));
602 CHECK_LDBL_SAME(fmaxl, ( +0.0L, -0.0L));
603 CHECK_LDBL_SAME(fmaxl, ( -0.0L, +0.0L));
604 CHECK_LDBL_SAME(fmaxl, ( -0.0L, -0.0L));
605 CHECK_LDBL_SAME(fmaxl, (+INFINITY, +INFINITY));
606 CHECK_LDBL_SAME(fmaxl, (-INFINITY, -INFINITY));
607 CHECK_LDBL_SAME(fmaxl, (+INFINITY, -INFINITY));
608 CHECK_LDBL_SAME(fmaxl, (-INFINITY, +INFINITY));
609 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble(NULL, true), -42.4242424242e222L));
610 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble(NULL, false), -42.4242424242e222L));
611 CHECK_LDBL_SAME(fmaxl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, true)));
612 CHECK_LDBL_SAME(fmaxl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, false)));
613 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble("2", false), RTStrNanLongDouble(NULL, false)));
614 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble("3", true), RTStrNanLongDouble(NULL, false)));
615 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble("4sig", true), RTStrNanLongDouble(NULL, false)));
616}
617
618
619void testFmin()
620{
621 RTTestSub(g_hTest, "fmin[fl]");
622
623 CHECK_DBL(RT_NOCRT(fmin)( 1.0, 1.0), 1.0);
624 CHECK_DBL(RT_NOCRT(fmin)( 4.0, 2.0), 2.0);
625 CHECK_DBL(RT_NOCRT(fmin)( 2.0, 4.0), 2.0);
626 CHECK_DBL(RT_NOCRT(fmin)(-2.0, -4.0), -4.0);
627 CHECK_DBL(RT_NOCRT(fmin)(-2.0, -4.0e+10), -4.0e+10);
628 CHECK_DBL(RT_NOCRT(fmin)(+INFINITY, +INFINITY), +INFINITY);
629 CHECK_DBL(RT_NOCRT(fmin)(-INFINITY, -INFINITY), -INFINITY);
630 CHECK_DBL(RT_NOCRT(fmin)(+INFINITY, -INFINITY), -INFINITY);
631 CHECK_DBL(RT_NOCRT(fmin)(-INFINITY, +INFINITY), -INFINITY);
632 CHECK_DBL_SAME(fmin, ( 99.99, 99.87));
633 CHECK_DBL_SAME(fmin, ( -99.99, -99.87));
634 CHECK_DBL_SAME(fmin, (-987.453, 34599.87));
635 CHECK_DBL_SAME(fmin, (34599.87, -987.453));
636 CHECK_DBL_SAME(fmin, ( +0.0, -0.0));
637 CHECK_DBL_SAME(fmin, ( -0.0, +0.0));
638 CHECK_DBL_SAME(fmin, ( -0.0, -0.0));
639 CHECK_DBL_SAME(fmin, (+INFINITY, +INFINITY));
640 CHECK_DBL_SAME(fmin, (-INFINITY, -INFINITY));
641 CHECK_DBL_SAME(fmin, (+INFINITY, -INFINITY));
642 CHECK_DBL_SAME(fmin, (-INFINITY, +INFINITY));
643 CHECK_DBL_SAME(fmin, (RTStrNanDouble(NULL, true), -42.4242424242e222));
644 CHECK_DBL_SAME(fmin, (RTStrNanDouble(NULL, false), -42.4242424242e222));
645 CHECK_DBL_SAME(fmin, (-42.4242424242e-222, RTStrNanDouble(NULL, true)));
646 CHECK_DBL_SAME(fmin, (-42.4242424242e-222, RTStrNanDouble(NULL, false)));
647 CHECK_DBL_SAME(fmin, (RTStrNanDouble("2", false), RTStrNanDouble(NULL, false)));
648 CHECK_DBL_SAME(fmin, (RTStrNanDouble("3", true), RTStrNanDouble(NULL, false)));
649 CHECK_DBL_SAME(fmin, (RTStrNanDouble("4sig", true), RTStrNanDouble(NULL, false)));
650
651 CHECK_FLT(RT_NOCRT(fmin)( 1.0f, 1.0f), 1.0f);
652 CHECK_FLT(RT_NOCRT(fmin)( 4.0f, 2.0f), 2.0f);
653 CHECK_FLT(RT_NOCRT(fmin)( 2.0f, 4.0f), 2.0f);
654 CHECK_FLT(RT_NOCRT(fmin)(-2.0f, -4.0f), -4.0f);
655 CHECK_FLT(RT_NOCRT(fmin)(-2.0f, -4.0e+10f), -4.0e+10f);
656 CHECK_FLT(RT_NOCRT(fmin)(+INFINITY, +INFINITY), +INFINITY);
657 CHECK_FLT(RT_NOCRT(fmin)(-INFINITY, -INFINITY), -INFINITY);
658 CHECK_FLT(RT_NOCRT(fmin)(+INFINITY, -INFINITY), -INFINITY);
659 CHECK_FLT(RT_NOCRT(fmin)(-INFINITY, +INFINITY), -INFINITY);
660 CHECK_FLT_SAME(fminf, ( 99.99f, 99.87f));
661 CHECK_FLT_SAME(fminf, ( -99.99f, -99.87f));
662 CHECK_FLT_SAME(fminf, (-987.453f, 34599.87f));
663 CHECK_FLT_SAME(fminf, (34599.87f, -987.453f));
664 CHECK_FLT_SAME(fminf, ( +0.0f, -0.0f));
665 CHECK_FLT_SAME(fminf, ( -0.0f, +0.0f));
666 CHECK_FLT_SAME(fminf, ( -0.0f, -0.0f));
667 CHECK_FLT_SAME(fminf, (+INFINITY, +INFINITY));
668 CHECK_FLT_SAME(fminf, (-INFINITY, -INFINITY));
669 CHECK_FLT_SAME(fminf, (+INFINITY, -INFINITY));
670 CHECK_FLT_SAME(fminf, (-INFINITY, +INFINITY));
671 CHECK_FLT_SAME(fminf, (RTStrNanFloat(NULL, true), -42.4242424242e22f));
672 CHECK_FLT_SAME(fminf, (RTStrNanFloat(NULL, false), -42.4242424242e22f));
673 CHECK_FLT_SAME(fminf, (-42.42424242e-22f, RTStrNanFloat(NULL, true)));
674 CHECK_FLT_SAME(fminf, (-42.42424242e-22f, RTStrNanFloat(NULL, false)));
675 CHECK_FLT_SAME(fminf, (RTStrNanFloat("2", false), RTStrNanFloat(NULL, false)));
676 CHECK_FLT_SAME(fminf, (RTStrNanFloat("3", true), RTStrNanFloat(NULL, false)));
677 CHECK_FLT_SAME(fminf, (RTStrNanFloat("4sig", true), RTStrNanFloat(NULL, false)));
678
679 CHECK_LDBL(RT_NOCRT(fmin)( 1.0L, 1.0L), 1.0L);
680 CHECK_LDBL(RT_NOCRT(fmin)( 4.0L, 2.0L), 2.0L);
681 CHECK_LDBL(RT_NOCRT(fmin)( 2.0L, 4.0L), 2.0L);
682 CHECK_LDBL(RT_NOCRT(fmin)(-2.0L, -4.0L), -4.0L);
683 CHECK_LDBL(RT_NOCRT(fmin)(-2.0L, -4.0e+10L), -4.0e+10L);
684 CHECK_LDBL(RT_NOCRT(fmin)(+INFINITY, +INFINITY), +INFINITY);
685 CHECK_LDBL(RT_NOCRT(fmin)(-INFINITY, -INFINITY), -INFINITY);
686 CHECK_LDBL(RT_NOCRT(fmin)(+INFINITY, -INFINITY), -INFINITY);
687 CHECK_LDBL(RT_NOCRT(fmin)(-INFINITY, +INFINITY), -INFINITY);
688 CHECK_LDBL_SAME(fminl, ( 99.99L, 99.87L));
689 CHECK_LDBL_SAME(fminl, ( -99.99L, -99.87L));
690 CHECK_LDBL_SAME(fminl, (-987.453L, 34599.87L));
691 CHECK_LDBL_SAME(fminl, (34599.87L, -987.453L));
692 CHECK_LDBL_SAME(fminl, ( +0.0L, -0.0L));
693 CHECK_LDBL_SAME(fminl, ( -0.0L, +0.0L));
694 CHECK_LDBL_SAME(fminl, ( -0.0L, -0.0L));
695 CHECK_LDBL_SAME(fminl, (+INFINITY, +INFINITY));
696 CHECK_LDBL_SAME(fminl, (-INFINITY, -INFINITY));
697 CHECK_LDBL_SAME(fminl, (+INFINITY, -INFINITY));
698 CHECK_LDBL_SAME(fminl, (-INFINITY, +INFINITY));
699 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble(NULL, true), -42.4242424242e222L));
700 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble(NULL, false), -42.4242424242e222L));
701 CHECK_LDBL_SAME(fminl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, true)));
702 CHECK_LDBL_SAME(fminl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, false)));
703 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble("2", false), RTStrNanLongDouble(NULL, false)));
704 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble("3", true), RTStrNanLongDouble(NULL, false)));
705 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble("4sig", true), RTStrNanLongDouble(NULL, false)));
706}
707
708
709void testIsInf()
710{
711 RTTestSub(g_hTest, "isinf,__isinf[fl]");
712#undef isinf
713 CHECK_INT(RT_NOCRT(isinf)( 1.0), 0);
714 CHECK_INT(RT_NOCRT(isinf)( 2394.2340e200), 0);
715 CHECK_INT(RT_NOCRT(isinf)(-2394.2340e200), 0);
716 CHECK_INT(RT_NOCRT(isinf)(-INFINITY), 1);
717 CHECK_INT(RT_NOCRT(isinf)(+INFINITY), 1);
718 CHECK_INT(RT_NOCRT(isinf)(RTStrNanDouble(NULL, true)), 0);
719 CHECK_INT(RT_NOCRT(isinf)(RTStrNanDouble("4sig", false)), 0);
720
721 CHECK_INT(RT_NOCRT(__isinff)( 1.0f), 0);
722 CHECK_INT(RT_NOCRT(__isinff)( 2394.2340e20f), 0);
723 CHECK_INT(RT_NOCRT(__isinff)(-2394.2340e20f), 0);
724 CHECK_INT(RT_NOCRT(__isinff)(-INFINITY), 1);
725 CHECK_INT(RT_NOCRT(__isinff)(+INFINITY), 1);
726 CHECK_INT(RT_NOCRT(__isinff)(RTStrNanFloat(NULL, true)), 0);
727 CHECK_INT(RT_NOCRT(__isinff)(RTStrNanFloat("4sig", false)), 0);
728
729 CHECK_INT(RT_NOCRT(__isinfl)( 1.0L), 0);
730 CHECK_INT(RT_NOCRT(__isinfl)( 2394.2340e200L), 0);
731 CHECK_INT(RT_NOCRT(__isinfl)(-2394.2340e200L), 0);
732 CHECK_INT(RT_NOCRT(__isinfl)(-INFINITY), 1);
733 CHECK_INT(RT_NOCRT(__isinfl)(+INFINITY), 1);
734 CHECK_INT(RT_NOCRT(__isinfl)(RTStrNanLongDouble(NULL, true)), 0);
735 CHECK_INT(RT_NOCRT(__isinfl)(RTStrNanLongDouble("4sig", false)), 0);
736}
737
738
739void testIsNan()
740{
741 RTTestSub(g_hTest, "isnan[f],__isnanl");
742#undef isnan
743 CHECK_INT(RT_NOCRT(isnan)( 0.0), 0);
744 CHECK_INT(RT_NOCRT(isnan)( 1.0), 0);
745 CHECK_INT(RT_NOCRT(isnan)( 2394.2340e200), 0);
746 CHECK_INT(RT_NOCRT(isnan)(-2394.2340e200), 0);
747 CHECK_INT(RT_NOCRT(isnan)(-INFINITY), 0);
748 CHECK_INT(RT_NOCRT(isnan)(+INFINITY), 0);
749 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble(NULL, true)), 1);
750 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble(NULL, false)), 1);
751 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("435876quiet", false)), 1);
752 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("435876quiet", true)), 1);
753 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("678sig", false)), 1);
754 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("45547absig", true)), 1);
755
756 CHECK_INT(RT_NOCRT(isnanf)( 0.0f), 0);
757 CHECK_INT(RT_NOCRT(isnanf)( 1.0f), 0);
758 CHECK_INT(RT_NOCRT(isnanf)( 2394.2340e20f), 0);
759 CHECK_INT(RT_NOCRT(isnanf)(-2394.2340e20f), 0);
760 CHECK_INT(RT_NOCRT(isnanf)(-INFINITY), 0);
761 CHECK_INT(RT_NOCRT(isnanf)(+INFINITY), 0);
762 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat(NULL, true)), 1);
763 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat(NULL, false)), 1);
764 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("9560q", false)), 1);
765 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("aaaaq", true)), 1);
766 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("4sig", false)), 1);
767 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("69504sig", true)), 1);
768
769 CHECK_INT(RT_NOCRT(__isnanl)( 0.0L), 0);
770 CHECK_INT(RT_NOCRT(__isnanl)( 1.0L), 0);
771 CHECK_INT(RT_NOCRT(__isnanl)( 2394.2340e200L), 0);
772 CHECK_INT(RT_NOCRT(__isnanl)(-2394.2340e200L), 0);
773 CHECK_INT(RT_NOCRT(__isnanl)(-INFINITY), 0);
774 CHECK_INT(RT_NOCRT(__isnanl)(+INFINITY), 0);
775 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble(NULL, true)), 1);
776 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble(NULL, false)), 1);
777 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("bbbbq", false)), 1);
778 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("11122q", true)), 1);
779 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("4sig", false)), 1);
780 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("23423406sig", true)), 1);
781}
782
783
784void testIsFinite()
785{
786 RTTestSub(g_hTest, "__isfinite[fl]");
787 CHECK_INT(RT_NOCRT(__isfinite)( 1.0), 1);
788 CHECK_INT(RT_NOCRT(__isfinite)( 2394.2340e200), 1);
789 CHECK_INT(RT_NOCRT(__isfinite)(-2394.2340e200), 1);
790 CHECK_INT(RT_NOCRT(__isfinite)(-2.1984e-310), 1); /* subnormal */
791 CHECK_INT(RT_NOCRT(__isfinite)(-INFINITY), 0);
792 CHECK_INT(RT_NOCRT(__isfinite)(+INFINITY), 0);
793 CHECK_INT(RT_NOCRT(__isfinite)(RTStrNanDouble(NULL, true)), 0);
794 CHECK_INT(RT_NOCRT(__isfinite)(RTStrNanDouble("4sig", false)), 0);
795
796 CHECK_INT(RT_NOCRT(__isfinitef)( 1.0f), 1);
797 CHECK_INT(RT_NOCRT(__isfinitef)( 2394.2340e20f), 1);
798 CHECK_INT(RT_NOCRT(__isfinitef)(-2394.2340e20f), 1);
799 CHECK_INT(RT_NOCRT(__isfinitef)(-2.1984e-40f), 1); /* subnormal */
800 CHECK_INT(RT_NOCRT(__isfinitef)(-INFINITY), 0);
801 CHECK_INT(RT_NOCRT(__isfinitef)(+INFINITY), 0);
802 CHECK_INT(RT_NOCRT(__isfinitef)(RTStrNanFloat(NULL, true)), 0);
803 CHECK_INT(RT_NOCRT(__isfinitef)(RTStrNanFloat("4sig", false)), 0);
804
805 CHECK_INT(RT_NOCRT(__isfinitel)( 1.0L), 1);
806 CHECK_INT(RT_NOCRT(__isfinitel)( 2394.2340e200L), 1);
807 CHECK_INT(RT_NOCRT(__isfinitel)(-2394.2340e200L), 1);
808#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
809 CHECK_INT(RT_NOCRT(__isfinitel)(-2.1984e-310L), 1); /* subnormal */
810#else
811 CHECK_INT(RT_NOCRT(__isfinitel)(-2.1984e-4935L), 1); /* subnormal */
812#endif
813 CHECK_INT(RT_NOCRT(__isfinitel)(-INFINITY), 0);
814 CHECK_INT(RT_NOCRT(__isfinitel)(+INFINITY), 0);
815 CHECK_INT(RT_NOCRT(__isfinitel)(RTStrNanLongDouble(NULL, true)), 0);
816 CHECK_INT(RT_NOCRT(__isfinitel)(RTStrNanLongDouble("4sig", false)), 0);
817}
818
819
820void testIsNormal()
821{
822 RTTestSub(g_hTest, "__isnormal[fl]");
823 CHECK_INT(RT_NOCRT(__isnormal)( 1.0), 1);
824 CHECK_INT(RT_NOCRT(__isnormal)( 2394.2340e200), 1);
825 CHECK_INT(RT_NOCRT(__isnormal)(-2394.2340e200), 1);
826 CHECK_INT(RT_NOCRT(__isnormal)(-2.1984e-310), 0); /* subnormal */
827 CHECK_INT(RT_NOCRT(__isnormal)(-INFINITY), 0);
828 CHECK_INT(RT_NOCRT(__isnormal)(+INFINITY), 0);
829 CHECK_INT(RT_NOCRT(__isnormal)(RTStrNanDouble(NULL, true)), 0);
830 CHECK_INT(RT_NOCRT(__isnormal)(RTStrNanDouble("4sig", false)), 0);
831
832 CHECK_INT(RT_NOCRT(__isnormalf)( 1.0f), 1);
833 CHECK_INT(RT_NOCRT(__isnormalf)( 2394.2340e20f), 1);
834 CHECK_INT(RT_NOCRT(__isnormalf)(-2394.2340e20f), 1);
835 CHECK_INT(RT_NOCRT(__isnormalf)(-2.1984e-40f), 0); /* subnormal */
836 CHECK_INT(RT_NOCRT(__isnormalf)(-INFINITY), 0);
837 CHECK_INT(RT_NOCRT(__isnormalf)(+INFINITY), 0);
838 CHECK_INT(RT_NOCRT(__isnormalf)(RTStrNanFloat(NULL, true)), 0);
839 CHECK_INT(RT_NOCRT(__isnormalf)(RTStrNanFloat("4sig", false)), 0);
840
841 CHECK_INT(RT_NOCRT(__isnormall)( 1.0L), 1);
842 CHECK_INT(RT_NOCRT(__isnormall)( 2394.2340e200L), 1);
843 CHECK_INT(RT_NOCRT(__isnormall)(-2394.2340e200L), 1);
844#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
845 CHECK_INT(RT_NOCRT(__isnormall)(-2.1984e-310L), 0); /* subnormal */
846#else
847 CHECK_INT(RT_NOCRT(__isnormall)(-2.1984e-4935L), 0); /* subnormal */
848#endif
849 CHECK_INT(RT_NOCRT(__isnormall)(-INFINITY), 0);
850 CHECK_INT(RT_NOCRT(__isnormall)(+INFINITY), 0);
851 CHECK_INT(RT_NOCRT(__isnormall)(RTStrNanLongDouble(NULL, true)), 0);
852 CHECK_INT(RT_NOCRT(__isnormall)(RTStrNanLongDouble("4sig", false)), 0);
853}
854
855
856void testFpClassify()
857{
858 RTTestSub(g_hTest, "__fpclassify[dfl]");
859 CHECK_INT(RT_NOCRT(__fpclassifyd)( +0.0), RT_NOCRT_FP_ZERO);
860 CHECK_INT(RT_NOCRT(__fpclassifyd)( -0.0), RT_NOCRT_FP_ZERO);
861 CHECK_INT(RT_NOCRT(__fpclassifyd)( 1.0), RT_NOCRT_FP_NORMAL);
862 CHECK_INT(RT_NOCRT(__fpclassifyd)( 2394.2340e200), RT_NOCRT_FP_NORMAL);
863 CHECK_INT(RT_NOCRT(__fpclassifyd)(-2394.2340e200), RT_NOCRT_FP_NORMAL);
864 CHECK_INT(RT_NOCRT(__fpclassifyd)(-2.1984e-310), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
865 CHECK_INT(RT_NOCRT(__fpclassifyd)(-INFINITY), RT_NOCRT_FP_INFINITE);
866 CHECK_INT(RT_NOCRT(__fpclassifyd)(+INFINITY), RT_NOCRT_FP_INFINITE);
867 CHECK_INT(RT_NOCRT(__fpclassifyd)(RTStrNanDouble(NULL, true)), RT_NOCRT_FP_NAN);
868 CHECK_INT(RT_NOCRT(__fpclassifyd)(RTStrNanDouble("4sig", false)), RT_NOCRT_FP_NAN);
869
870 CHECK_INT(RT_NOCRT(__fpclassifyf)( +0.0f), RT_NOCRT_FP_ZERO);
871 CHECK_INT(RT_NOCRT(__fpclassifyf)( -0.0f), RT_NOCRT_FP_ZERO);
872 CHECK_INT(RT_NOCRT(__fpclassifyf)( 1.0f), RT_NOCRT_FP_NORMAL);
873 CHECK_INT(RT_NOCRT(__fpclassifyf)( 2394.2340e20f), RT_NOCRT_FP_NORMAL);
874 CHECK_INT(RT_NOCRT(__fpclassifyf)(-2394.2340e20f), RT_NOCRT_FP_NORMAL);
875 CHECK_INT(RT_NOCRT(__fpclassifyf)(-2.1984e-40f), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
876 CHECK_INT(RT_NOCRT(__fpclassifyf)(-INFINITY), RT_NOCRT_FP_INFINITE);
877 CHECK_INT(RT_NOCRT(__fpclassifyf)(+INFINITY), RT_NOCRT_FP_INFINITE);
878 CHECK_INT(RT_NOCRT(__fpclassifyf)(RTStrNanFloat(NULL, true)), RT_NOCRT_FP_NAN);
879 CHECK_INT(RT_NOCRT(__fpclassifyf)(RTStrNanFloat("4sig", false)), RT_NOCRT_FP_NAN);
880
881 CHECK_INT(RT_NOCRT(__fpclassifyl)( +0.0L), RT_NOCRT_FP_ZERO);
882 CHECK_INT(RT_NOCRT(__fpclassifyl)( -0.0L), RT_NOCRT_FP_ZERO);
883 CHECK_INT(RT_NOCRT(__fpclassifyl)( 1.0L), RT_NOCRT_FP_NORMAL);
884 CHECK_INT(RT_NOCRT(__fpclassifyl)( 2394.2340e200L), RT_NOCRT_FP_NORMAL);
885 CHECK_INT(RT_NOCRT(__fpclassifyl)(-2394.2340e200L), RT_NOCRT_FP_NORMAL);
886#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
887 CHECK_INT(RT_NOCRT(__fpclassifyl)(-2.1984e-310L), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
888#else
889 CHECK_INT(RT_NOCRT(__fpclassifyl)(-2.1984e-4935L), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
890#endif
891 CHECK_INT(RT_NOCRT(__fpclassifyl)(-INFINITY), RT_NOCRT_FP_INFINITE);
892 CHECK_INT(RT_NOCRT(__fpclassifyl)(+INFINITY), RT_NOCRT_FP_INFINITE);
893 CHECK_INT(RT_NOCRT(__fpclassifyl)(RTStrNanLongDouble(NULL, true)), RT_NOCRT_FP_NAN);
894 CHECK_INT(RT_NOCRT(__fpclassifyl)(RTStrNanLongDouble("4sig", false)), RT_NOCRT_FP_NAN);
895}
896
897
898void testSignBit()
899{
900 RTTestSub(g_hTest, "__signbit[fl]");
901 CHECK_INT(RT_NOCRT(__signbit)( +0.0), 0);
902 CHECK_INT(RT_NOCRT(__signbit)( -0.0), 1);
903 CHECK_INT(RT_NOCRT(__signbit)( 1.0), 0);
904 CHECK_INT(RT_NOCRT(__signbit)( 2394.2340e200), 0);
905 CHECK_INT(RT_NOCRT(__signbit)(-2394.2340e200), 1);
906 CHECK_INT(RT_NOCRT(__signbit)(-2.1984e-310), 1); /* subnormal */
907 CHECK_INT(RT_NOCRT(__signbit)(-INFINITY), 1);
908 CHECK_INT(RT_NOCRT(__signbit)(+INFINITY), 0);
909 CHECK_INT(RT_NOCRT(__signbit)(RTStrNanDouble(NULL, true)), 0);
910 CHECK_INT(RT_NOCRT(__signbit)(RTStrNanDouble("4sig", false)), 1);
911
912 CHECK_INT(RT_NOCRT(__signbitf)( +0.0f), 0);
913 CHECK_INT(RT_NOCRT(__signbitf)( -0.0f), 1);
914 CHECK_INT(RT_NOCRT(__signbitf)( 1.0f), 0);
915 CHECK_INT(RT_NOCRT(__signbitf)( 2394.2340e20f), 0);
916 CHECK_INT(RT_NOCRT(__signbitf)(-2394.2340e20f), 1);
917 CHECK_INT(RT_NOCRT(__signbitf)(-2.1984e-40f), 1); /* subnormal */
918 CHECK_INT(RT_NOCRT(__signbitf)(-INFINITY), 1);
919 CHECK_INT(RT_NOCRT(__signbitf)(+INFINITY), 0);
920 CHECK_INT(RT_NOCRT(__signbitf)(RTStrNanFloat(NULL, true)), 0);
921 CHECK_INT(RT_NOCRT(__signbitf)(RTStrNanFloat("4sig", false)), 1);
922
923 CHECK_INT(RT_NOCRT(__signbitl)( +0.0L), 0);
924 CHECK_INT(RT_NOCRT(__signbitl)( -0.0L), 1);
925 CHECK_INT(RT_NOCRT(__signbitl)( 1.0L), 0);
926 CHECK_INT(RT_NOCRT(__signbitl)( 2394.2340e200L), 0);
927 CHECK_INT(RT_NOCRT(__signbitl)(-2394.2340e200L), 1);
928#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
929 CHECK_INT(RT_NOCRT(__signbitl)(-2.1984e-310L), 1); /* subnormal */
930#else
931 CHECK_INT(RT_NOCRT(__signbitl)(-2.1984e-4935L), 1); /* subnormal */
932#endif
933 CHECK_INT(RT_NOCRT(__signbitl)(-INFINITY), 1);
934 CHECK_INT(RT_NOCRT(__signbitl)(+INFINITY), 0);
935 CHECK_INT(RT_NOCRT(__signbitl)(RTStrNanLongDouble(NULL, true)), 0);
936 CHECK_INT(RT_NOCRT(__signbitl)(RTStrNanLongDouble("4sig", false)), 1);
937}
938
939
940void testCeil()
941{
942 RTTestSub(g_hTest, "ceil[f]");
943 CHECK_DBL(RT_NOCRT(ceil)( +0.0), +0.0);
944 CHECK_DBL(RT_NOCRT(ceil)( -0.0), -0.0);
945 CHECK_DBL(RT_NOCRT(ceil)( -42.0), -42.0);
946 CHECK_DBL(RT_NOCRT(ceil)( -42.5), -42.0);
947 CHECK_DBL(RT_NOCRT(ceil)( +42.5), +43.0);
948 CHECK_DBL(RT_NOCRT(ceil)(-42.25), -42.0);
949 CHECK_DBL(RT_NOCRT(ceil)(+42.25), +43.0);
950 CHECK_DBL_SAME(ceil,( -0.0));
951 CHECK_DBL_SAME(ceil,( +0.0));
952 CHECK_DBL_SAME(ceil,( +42.25));
953 CHECK_DBL_SAME(ceil,(+1234.60958634e+10));
954 CHECK_DBL_SAME(ceil,(-1234.60958634e+10));
955 CHECK_DBL_SAME(ceil,( -1234.499999e+10));
956 CHECK_DBL_SAME(ceil,( -1234.499999e-10));
957 CHECK_DBL_SAME(ceil,( -2.1984e-310)); /* subnormal */
958 CHECK_DBL_SAME(ceil,(-INFINITY));
959 CHECK_DBL_SAME(ceil,(+INFINITY));
960 CHECK_DBL_SAME(ceil,(RTStrNanDouble(NULL, true)));
961 CHECK_DBL_SAME(ceil,(RTStrNanDouble("s", false)));
962
963 CHECK_DBL(RT_NOCRT(ceilf)( +0.0f), +0.0f);
964 CHECK_DBL(RT_NOCRT(ceilf)( -0.0f), -0.0f);
965 CHECK_DBL(RT_NOCRT(ceilf)( -42.0f), -42.0f);
966 CHECK_DBL(RT_NOCRT(ceilf)( -42.5f), -42.0f);
967 CHECK_DBL(RT_NOCRT(ceilf)( +42.5f), +43.0f);
968 CHECK_DBL(RT_NOCRT(ceilf)(-42.25f), -42.0f);
969 CHECK_DBL(RT_NOCRT(ceilf)(+42.25f), +43.0f);
970 CHECK_DBL_SAME(ceilf,( -0.0f));
971 CHECK_DBL_SAME(ceilf,( +0.0f));
972 CHECK_DBL_SAME(ceilf,( +42.25f));
973 CHECK_DBL_SAME(ceilf,(+1234.60958634e+10f));
974 CHECK_DBL_SAME(ceilf,(-1234.60958634e+10f));
975 CHECK_DBL_SAME(ceilf,( -1234.499999e+10f));
976 CHECK_DBL_SAME(ceilf,( -1234.499999e-10f));
977 CHECK_DBL_SAME(ceilf,( -2.1984e-40f)); /* subnormal */
978 CHECK_DBL_SAME(ceilf,(-INFINITY));
979 CHECK_DBL_SAME(ceilf,(+INFINITY));
980 CHECK_DBL_SAME(ceilf,(RTStrNanFloat(NULL, true)));
981 CHECK_DBL_SAME(ceilf,(RTStrNanFloat("s", false)));
982}
983
984
985void testFloor()
986{
987 RTTestSub(g_hTest, "floor[f]");
988 CHECK_DBL(RT_NOCRT(floor)( +0.0), +0.0);
989 CHECK_DBL(RT_NOCRT(floor)( -0.0), -0.0);
990 CHECK_DBL(RT_NOCRT(floor)( -42.0), -42.0);
991 CHECK_DBL(RT_NOCRT(floor)( -42.5), -43.0);
992 CHECK_DBL(RT_NOCRT(floor)( +42.5), +42.0);
993 CHECK_DBL(RT_NOCRT(floor)(-42.25), -43.0);
994 CHECK_DBL(RT_NOCRT(floor)(+42.25), +42.0);
995 CHECK_DBL_SAME(floor,( -0.0));
996 CHECK_DBL_SAME(floor,( +0.0));
997 CHECK_DBL_SAME(floor,( +42.25));
998 CHECK_DBL_SAME(floor,(+1234.60958634e+10));
999 CHECK_DBL_SAME(floor,(-1234.60958634e+10));
1000 CHECK_DBL_SAME(floor,( -1234.499999e+10));
1001 CHECK_DBL_SAME(floor,( -1234.499999e-10));
1002 CHECK_DBL_SAME(floor,( -2.1984e-310)); /* subnormal */
1003 CHECK_DBL_SAME(floor,(-INFINITY));
1004 CHECK_DBL_SAME(floor,(+INFINITY));
1005 CHECK_DBL_SAME(floor,(RTStrNanDouble(NULL, true)));
1006 CHECK_DBL_SAME(floor,(RTStrNanDouble("s", false)));
1007
1008 CHECK_DBL(RT_NOCRT(floorf)( +0.0f), +0.0f);
1009 CHECK_DBL(RT_NOCRT(floorf)( -0.0f), -0.0f);
1010 CHECK_DBL(RT_NOCRT(floorf)( -42.0f), -42.0f);
1011 CHECK_DBL(RT_NOCRT(floorf)( -42.5f), -43.0f);
1012 CHECK_DBL(RT_NOCRT(floorf)( +42.5f), +42.0f);
1013 CHECK_DBL(RT_NOCRT(floorf)(-42.25f), -43.0f);
1014 CHECK_DBL(RT_NOCRT(floorf)(+42.25f), +42.0f);
1015 CHECK_DBL_SAME(floorf,( -0.0f));
1016 CHECK_DBL_SAME(floorf,( +0.0f));
1017 CHECK_DBL_SAME(floorf,( +42.25f));
1018 CHECK_DBL_SAME(floorf,(+1234.60958634e+10f));
1019 CHECK_DBL_SAME(floorf,(-1234.60958634e+10f));
1020 CHECK_DBL_SAME(floorf,( -1234.499999e+10f));
1021 CHECK_DBL_SAME(floorf,( -1234.499999e-10f));
1022 CHECK_DBL_SAME(floorf,( -2.1984e-40f)); /* subnormal */
1023 CHECK_DBL_SAME(floorf,(-INFINITY));
1024 CHECK_DBL_SAME(floorf,(+INFINITY));
1025 CHECK_DBL_SAME(floorf,(RTStrNanFloat(NULL, true)));
1026 CHECK_DBL_SAME(floorf,(RTStrNanFloat("s", false)));
1027}
1028
1029
1030void testTrunc()
1031{
1032 RTTestSub(g_hTest, "trunc[f]");
1033 CHECK_DBL(RT_NOCRT(trunc)( +0.0), +0.0);
1034 CHECK_DBL(RT_NOCRT(trunc)( -0.0), -0.0);
1035 CHECK_DBL(RT_NOCRT(trunc)( -42.0), -42.0);
1036 CHECK_DBL(RT_NOCRT(trunc)( -42.5), -42.0);
1037 CHECK_DBL(RT_NOCRT(trunc)( +42.5), +42.0);
1038 CHECK_DBL(RT_NOCRT(trunc)(-42.25), -42.0);
1039 CHECK_DBL(RT_NOCRT(trunc)(+42.25), +42.0);
1040 CHECK_DBL_SAME(trunc,( -0.0));
1041 CHECK_DBL_SAME(trunc,( +0.0));
1042 CHECK_DBL_SAME(trunc,( +42.25));
1043 CHECK_DBL_SAME(trunc,(+1234.60958634e+10));
1044 CHECK_DBL_SAME(trunc,(-1234.60958634e+10));
1045 CHECK_DBL_SAME(trunc,( -1234.499999e+10));
1046 CHECK_DBL_SAME(trunc,( -1234.499999e-10));
1047 CHECK_DBL_SAME(trunc,( -2.1984e-310)); /* subnormal */
1048 CHECK_DBL_SAME(trunc,(-INFINITY));
1049 CHECK_DBL_SAME(trunc,(+INFINITY));
1050 CHECK_DBL_SAME(trunc,(RTStrNanDouble(NULL, true)));
1051 CHECK_DBL_SAME(trunc,(RTStrNanDouble("s", false)));
1052
1053 CHECK_DBL(RT_NOCRT(truncf)( +0.0f), +0.0f);
1054 CHECK_DBL(RT_NOCRT(truncf)( -0.0f), -0.0f);
1055 CHECK_DBL(RT_NOCRT(truncf)( -42.0f), -42.0f);
1056 CHECK_DBL(RT_NOCRT(truncf)( -42.5f), -42.0f);
1057 CHECK_DBL(RT_NOCRT(truncf)( +42.5f), +42.0f);
1058 CHECK_DBL(RT_NOCRT(truncf)(-42.25f), -42.0f);
1059 CHECK_DBL(RT_NOCRT(truncf)(+42.25f), +42.0f);
1060 CHECK_DBL_SAME(truncf,( -0.0f));
1061 CHECK_DBL_SAME(truncf,( +0.0f));
1062 CHECK_DBL_SAME(truncf,( +42.25f));
1063 CHECK_DBL_SAME(truncf,(+1234.60958634e+10f));
1064 CHECK_DBL_SAME(truncf,(-1234.60958634e+10f));
1065 CHECK_DBL_SAME(truncf,( -1234.499999e+10f));
1066 CHECK_DBL_SAME(truncf,( -1234.499999e-10f));
1067 CHECK_DBL_SAME(truncf,( -2.1984e-40f)); /* subnormal */
1068 CHECK_DBL_SAME(truncf,(-INFINITY));
1069 CHECK_DBL_SAME(truncf,(+INFINITY));
1070 CHECK_DBL_SAME(truncf,(RTStrNanFloat(NULL, true)));
1071 CHECK_DBL_SAME(truncf,(RTStrNanFloat("s", false)));
1072}
1073
1074
1075void testRound()
1076{
1077 RTTestSub(g_hTest, "round[f]");
1078 CHECK_DBL(RT_NOCRT(round)( +0.0), +0.0);
1079 CHECK_DBL(RT_NOCRT(round)( -0.0), -0.0);
1080 CHECK_DBL(RT_NOCRT(round)( -42.0), -42.0);
1081 CHECK_DBL(RT_NOCRT(round)( -42.5), -43.0);
1082 CHECK_DBL(RT_NOCRT(round)( +42.5), +43.0);
1083 CHECK_DBL(RT_NOCRT(round)(-42.25), -42.0);
1084 CHECK_DBL(RT_NOCRT(round)(+42.25), +42.0);
1085 CHECK_DBL_SAME(round,( -0.0));
1086 CHECK_DBL_SAME(round,( +0.0));
1087 CHECK_DBL_SAME(round,( +42.25));
1088 CHECK_DBL_SAME(round,(+1234.60958634e+10));
1089 CHECK_DBL_SAME(round,(-1234.60958634e+10));
1090 CHECK_DBL_SAME(round,( -1234.499999e+10));
1091 CHECK_DBL_SAME(round,( -1234.499999e-10));
1092 CHECK_DBL_SAME(round,( -2.1984e-310)); /* subnormal */
1093 CHECK_DBL_SAME(round,(-INFINITY));
1094 CHECK_DBL_SAME(round,(+INFINITY));
1095 CHECK_DBL_SAME(round,(RTStrNanDouble(NULL, true)));
1096 CHECK_DBL_SAME(round,(RTStrNanDouble("s", false)));
1097
1098 CHECK_DBL(RT_NOCRT(roundf)( +0.0f), +0.0f);
1099 CHECK_DBL(RT_NOCRT(roundf)( -0.0f), -0.0f);
1100 CHECK_DBL(RT_NOCRT(roundf)( -42.0f), -42.0f);
1101 CHECK_DBL(RT_NOCRT(roundf)( -42.5f), -43.0f);
1102 CHECK_DBL(RT_NOCRT(roundf)( +42.5f), +43.0f);
1103 CHECK_DBL(RT_NOCRT(roundf)(-42.25f), -42.0f);
1104 CHECK_DBL(RT_NOCRT(roundf)(+42.25f), +42.0f);
1105 CHECK_DBL_SAME(roundf,( -0.0f));
1106 CHECK_DBL_SAME(roundf,( +0.0f));
1107 CHECK_DBL_SAME(roundf,( +42.25f));
1108 CHECK_DBL_SAME(roundf,(+1234.60958634e+10f));
1109 CHECK_DBL_SAME(roundf,(-1234.60958634e+10f));
1110 CHECK_DBL_SAME(roundf,( -1234.499999e+10f));
1111 CHECK_DBL_SAME(roundf,( -1234.499999e-10f));
1112 CHECK_DBL_SAME(roundf,( -2.1984e-40f)); /* subnormal */
1113 CHECK_DBL_SAME(roundf,(-INFINITY));
1114 CHECK_DBL_SAME(roundf,(+INFINITY));
1115 CHECK_DBL_SAME(roundf,(RTStrNanFloat(NULL, true)));
1116 CHECK_DBL_SAME(roundf,(RTStrNanFloat("s", false)));
1117}
1118
1119
1120void testRInt()
1121{
1122 RTTestSub(g_hTest, "rint[f]");
1123
1124 /*
1125 * Round nearest.
1126 */
1127#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
1128 AssertCompile(RT_NOCRT_FE_TONEAREST == X86_FCW_RC_NEAREST);
1129 AssertCompile(RT_NOCRT_FE_DOWNWARD == X86_FCW_RC_DOWN);
1130 AssertCompile(RT_NOCRT_FE_UPWARD == X86_FCW_RC_UP);
1131 AssertCompile(RT_NOCRT_FE_TOWARDZERO == X86_FCW_RC_ZERO);
1132 AssertCompile(RT_NOCRT_FE_ROUND_MASK == X86_FCW_RC_MASK);
1133#endif
1134 int const iSavedMode = RT_NOCRT(fegetround)();
1135 if (iSavedMode != FE_TONEAREST)
1136 RTTestFailed(g_hTest, "expected FE_TONEAREST as default rounding mode, not %#x (%d)", iSavedMode, iSavedMode);
1137 RT_NOCRT(fesetround)(FE_TONEAREST);
1138
1139 CHECK_DBL(RT_NOCRT(rint)( +0.0), +0.0);
1140 CHECK_DBL(RT_NOCRT(rint)( -0.0), -0.0);
1141 CHECK_DBL(RT_NOCRT(rint)( -42.0), -42.0);
1142 CHECK_DBL(RT_NOCRT(rint)( -42.5), -42.0);
1143 CHECK_DBL(RT_NOCRT(rint)( +42.5), +42.0);
1144 CHECK_DBL(RT_NOCRT(rint)( -43.5), -44.0);
1145 CHECK_DBL(RT_NOCRT(rint)( +43.5), +44.0);
1146 CHECK_DBL(RT_NOCRT(rint)(-42.25), -42.0);
1147 CHECK_DBL(RT_NOCRT(rint)(+42.25), +42.0);
1148 CHECK_DBL(RT_NOCRT(rint)(-42.75), -43.0);
1149 CHECK_DBL(RT_NOCRT(rint)(+42.75), +43.0);
1150 CHECK_DBL_SAME(rint,( -0.0));
1151 CHECK_DBL_SAME(rint,( +0.0));
1152 CHECK_DBL_SAME(rint,( +42.25));
1153 CHECK_DBL_SAME(rint,( +42.50));
1154 CHECK_DBL_SAME(rint,( +42.75));
1155 CHECK_DBL_SAME(rint,( -42.25));
1156 CHECK_DBL_SAME(rint,( -42.50));
1157 CHECK_DBL_SAME(rint,( -42.75));
1158 CHECK_DBL_SAME(rint,(+1234.60958634e+10));
1159 CHECK_DBL_SAME(rint,(-1234.60958634e+10));
1160 CHECK_DBL_SAME(rint,( -1234.499999e+10));
1161 CHECK_DBL_SAME(rint,( -1234.499999e-10));
1162 CHECK_DBL_SAME(rint,( -2.1984e-310)); /* subnormal */
1163 CHECK_DBL_SAME(rint,(-INFINITY));
1164 CHECK_DBL_SAME(rint,(+INFINITY));
1165 CHECK_DBL_SAME(rint,(RTStrNanDouble(NULL, true)));
1166 CHECK_DBL_SAME(rint,(RTStrNanDouble("s", false)));
1167
1168 CHECK_DBL(RT_NOCRT(rintf)( +0.0f), +0.0f);
1169 CHECK_DBL(RT_NOCRT(rintf)( -0.0f), -0.0f);
1170 CHECK_DBL(RT_NOCRT(rintf)( -42.0f), -42.0f);
1171 CHECK_DBL(RT_NOCRT(rintf)( -42.5f), -42.0f);
1172 CHECK_DBL(RT_NOCRT(rintf)( +42.5f), +42.0f);
1173 CHECK_DBL(RT_NOCRT(rintf)( -43.5f), -44.0f);
1174 CHECK_DBL(RT_NOCRT(rintf)( +43.5f), +44.0f);
1175 CHECK_DBL(RT_NOCRT(rintf)(-42.25f), -42.0f);
1176 CHECK_DBL(RT_NOCRT(rintf)(+42.25f), +42.0f);
1177 CHECK_DBL_SAME(rintf,( -0.0f));
1178 CHECK_DBL_SAME(rintf,( +0.0f));
1179 CHECK_DBL_SAME(rintf,( +42.25f));
1180 CHECK_DBL_SAME(rintf,( +42.50f));
1181 CHECK_DBL_SAME(rintf,( +42.75f));
1182 CHECK_DBL_SAME(rintf,( -42.25f));
1183 CHECK_DBL_SAME(rintf,( -42.50f));
1184 CHECK_DBL_SAME(rintf,( -42.75f));
1185 CHECK_DBL_SAME(rintf,(+1234.60958634e+10f));
1186 CHECK_DBL_SAME(rintf,(-1234.60958634e+10f));
1187 CHECK_DBL_SAME(rintf,( -1234.499999e+10f));
1188 CHECK_DBL_SAME(rintf,( -1234.499999e-10f));
1189 CHECK_DBL_SAME(rintf,( -2.1984e-40f)); /* subnormal */
1190 CHECK_DBL_SAME(rintf,(-INFINITY));
1191 CHECK_DBL_SAME(rintf,(+INFINITY));
1192 CHECK_DBL_SAME(rintf,(RTStrNanFloat(NULL, true)));
1193 CHECK_DBL_SAME(rintf,(RTStrNanFloat("s", false)));
1194
1195 /*
1196 * Round UP.
1197 */
1198 RT_NOCRT(fesetround)(FE_UPWARD);
1199
1200 CHECK_DBL(RT_NOCRT(rint)( +0.0), +0.0);
1201 CHECK_DBL(RT_NOCRT(rint)( -0.0), -0.0);
1202 CHECK_DBL(RT_NOCRT(rint)( -42.0), -42.0);
1203 CHECK_DBL(RT_NOCRT(rint)( -42.5), -42.0);
1204 CHECK_DBL(RT_NOCRT(rint)( +42.5), +43.0);
1205 CHECK_DBL(RT_NOCRT(rint)( -43.5), -43.0);
1206 CHECK_DBL(RT_NOCRT(rint)( +43.5), +44.0);
1207 CHECK_DBL(RT_NOCRT(rint)(-42.25), -42.0);
1208 CHECK_DBL(RT_NOCRT(rint)(+42.25), +43.0);
1209 CHECK_DBL(RT_NOCRT(rint)(-42.75), -42.0);
1210 CHECK_DBL(RT_NOCRT(rint)(+42.75), +43.0);
1211 CHECK_DBL_SAME(rint,( -0.0));
1212 CHECK_DBL_SAME(rint,( +0.0));
1213 CHECK_DBL_SAME(rint,( +42.25));
1214 CHECK_DBL_SAME(rint,( +42.50));
1215 CHECK_DBL_SAME(rint,( +42.75));
1216 CHECK_DBL_SAME(rint,( -42.25));
1217 CHECK_DBL_SAME(rint,( -42.50));
1218 CHECK_DBL_SAME(rint,( -42.75));
1219 CHECK_DBL_SAME(rint,(+1234.60958634e+10));
1220 CHECK_DBL_SAME(rint,(-1234.60958634e+10));
1221 CHECK_DBL_SAME(rint,( -1234.499999e+10));
1222 CHECK_DBL_SAME(rint,( -1234.499999e-10));
1223 CHECK_DBL_SAME(rint,( -2.1984e-310)); /* subnormal */
1224 CHECK_DBL_SAME(rint,(-INFINITY));
1225 CHECK_DBL_SAME(rint,(+INFINITY));
1226 CHECK_DBL_SAME(rint,(RTStrNanDouble(NULL, true)));
1227 CHECK_DBL_SAME(rint,(RTStrNanDouble("s", false)));
1228
1229 CHECK_DBL(RT_NOCRT(rintf)( +0.0f), +0.0f);
1230 CHECK_DBL(RT_NOCRT(rintf)( -0.0f), -0.0f);
1231 CHECK_DBL(RT_NOCRT(rintf)( -42.0f), -42.0f);
1232 CHECK_DBL(RT_NOCRT(rintf)( -42.5f), -42.0f);
1233 CHECK_DBL(RT_NOCRT(rintf)( +42.5f), +43.0f);
1234 CHECK_DBL(RT_NOCRT(rintf)( -43.5f), -43.0f);
1235 CHECK_DBL(RT_NOCRT(rintf)( +43.5f), +44.0f);
1236 CHECK_DBL(RT_NOCRT(rintf)(-42.25f), -42.0f);
1237 CHECK_DBL(RT_NOCRT(rintf)(+42.25f), +43.0f);
1238 CHECK_DBL_SAME(rintf,( -0.0f));
1239 CHECK_DBL_SAME(rintf,( +0.0f));
1240 CHECK_DBL_SAME(rintf,( +42.25f));
1241 CHECK_DBL_SAME(rintf,( +42.50f));
1242 CHECK_DBL_SAME(rintf,( +42.75f));
1243 CHECK_DBL_SAME(rintf,( -42.25f));
1244 CHECK_DBL_SAME(rintf,( -42.50f));
1245 CHECK_DBL_SAME(rintf,( -42.75f));
1246 CHECK_DBL_SAME(rintf,(+1234.60958634e+10f));
1247 CHECK_DBL_SAME(rintf,(-1234.60958634e+10f));
1248 CHECK_DBL_SAME(rintf,( -1234.499999e+10f));
1249 CHECK_DBL_SAME(rintf,( -1234.499999e-10f));
1250 CHECK_DBL_SAME(rintf,( -2.1984e-40f)); /* subnormal */
1251 CHECK_DBL_SAME(rintf,(-INFINITY));
1252 CHECK_DBL_SAME(rintf,(+INFINITY));
1253 CHECK_DBL_SAME(rintf,(RTStrNanFloat(NULL, true)));
1254 CHECK_DBL_SAME(rintf,(RTStrNanFloat("s", false)));
1255
1256 /*
1257 * Round DOWN.
1258 */
1259 RT_NOCRT(fesetround)(FE_DOWNWARD);
1260
1261 CHECK_DBL(RT_NOCRT(rint)( +0.0), +0.0);
1262 CHECK_DBL(RT_NOCRT(rint)( -0.0), -0.0);
1263 CHECK_DBL(RT_NOCRT(rint)( -42.0), -42.0);
1264 CHECK_DBL(RT_NOCRT(rint)( -42.5), -43.0);
1265 CHECK_DBL(RT_NOCRT(rint)( +42.5), +42.0);
1266 CHECK_DBL(RT_NOCRT(rint)( -43.5), -44.0);
1267 CHECK_DBL(RT_NOCRT(rint)( +43.5), +43.0);
1268 CHECK_DBL(RT_NOCRT(rint)(-42.25), -43.0);
1269 CHECK_DBL(RT_NOCRT(rint)(+42.25), +42.0);
1270 CHECK_DBL(RT_NOCRT(rint)(-42.75), -43.0);
1271 CHECK_DBL(RT_NOCRT(rint)(+42.75), +42.0);
1272 CHECK_DBL_SAME(rint,( -0.0));
1273 CHECK_DBL_SAME(rint,( +0.0));
1274 CHECK_DBL_SAME(rint,( +42.25));
1275 CHECK_DBL_SAME(rint,( +42.50));
1276 CHECK_DBL_SAME(rint,( +42.75));
1277 CHECK_DBL_SAME(rint,( -42.25));
1278 CHECK_DBL_SAME(rint,( -42.50));
1279 CHECK_DBL_SAME(rint,( -42.75));
1280 CHECK_DBL_SAME(rint,(+1234.60958634e+10));
1281 CHECK_DBL_SAME(rint,(-1234.60958634e+10));
1282 CHECK_DBL_SAME(rint,( -1234.499999e+10));
1283 CHECK_DBL_SAME(rint,( -1234.499999e-10));
1284 CHECK_DBL_SAME(rint,( -2.1984e-310)); /* subnormal */
1285 CHECK_DBL_SAME(rint,(-INFINITY));
1286 CHECK_DBL_SAME(rint,(+INFINITY));
1287 CHECK_DBL_SAME(rint,(RTStrNanDouble(NULL, true)));
1288 CHECK_DBL_SAME(rint,(RTStrNanDouble("s", false)));
1289
1290 CHECK_DBL(RT_NOCRT(rintf)( +0.0f), +0.0f);
1291 CHECK_DBL(RT_NOCRT(rintf)( -0.0f), -0.0f);
1292 CHECK_DBL(RT_NOCRT(rintf)( -42.0f), -42.0f);
1293 CHECK_DBL(RT_NOCRT(rintf)( -42.5f), -43.0f);
1294 CHECK_DBL(RT_NOCRT(rintf)( +42.5f), +42.0f);
1295 CHECK_DBL(RT_NOCRT(rintf)( -43.5f), -44.0f);
1296 CHECK_DBL(RT_NOCRT(rintf)( +43.5f), +43.0f);
1297 CHECK_DBL(RT_NOCRT(rintf)(-42.25f), -43.0f);
1298 CHECK_DBL(RT_NOCRT(rintf)(+42.25f), +42.0f);
1299 CHECK_DBL_SAME(rintf,( -0.0f));
1300 CHECK_DBL_SAME(rintf,( +0.0f));
1301 CHECK_DBL_SAME(rintf,( +42.25f));
1302 CHECK_DBL_SAME(rintf,( +42.50f));
1303 CHECK_DBL_SAME(rintf,( +42.75f));
1304 CHECK_DBL_SAME(rintf,( -42.25f));
1305 CHECK_DBL_SAME(rintf,( -42.50f));
1306 CHECK_DBL_SAME(rintf,( -42.75f));
1307 CHECK_DBL_SAME(rintf,(+1234.60958634e+10f));
1308 CHECK_DBL_SAME(rintf,(-1234.60958634e+10f));
1309 CHECK_DBL_SAME(rintf,( -1234.499999e+10f));
1310 CHECK_DBL_SAME(rintf,( -1234.499999e-10f));
1311 CHECK_DBL_SAME(rintf,( -2.1984e-40f)); /* subnormal */
1312 CHECK_DBL_SAME(rintf,(-INFINITY));
1313 CHECK_DBL_SAME(rintf,(+INFINITY));
1314 CHECK_DBL_SAME(rintf,(RTStrNanFloat(NULL, true)));
1315 CHECK_DBL_SAME(rintf,(RTStrNanFloat("s", false)));
1316
1317 /*
1318 * Round towards ZERO.
1319 */
1320 RT_NOCRT(fesetround)(FE_TOWARDZERO);
1321
1322 CHECK_DBL(RT_NOCRT(rint)( +0.0), +0.0);
1323 CHECK_DBL(RT_NOCRT(rint)( -0.0), -0.0);
1324 CHECK_DBL(RT_NOCRT(rint)( -42.0), -42.0);
1325 CHECK_DBL(RT_NOCRT(rint)( -42.5), -42.0);
1326 CHECK_DBL(RT_NOCRT(rint)( +42.5), +42.0);
1327 CHECK_DBL(RT_NOCRT(rint)( -43.5), -43.0);
1328 CHECK_DBL(RT_NOCRT(rint)( +43.5), +43.0);
1329 CHECK_DBL(RT_NOCRT(rint)(-42.25), -42.0);
1330 CHECK_DBL(RT_NOCRT(rint)(+42.25), +42.0);
1331 CHECK_DBL(RT_NOCRT(rint)(-42.75), -42.0);
1332 CHECK_DBL(RT_NOCRT(rint)(+42.75), +42.0);
1333 CHECK_DBL_SAME(rint,( -0.0));
1334 CHECK_DBL_SAME(rint,( +0.0));
1335 CHECK_DBL_SAME(rint,( +42.25));
1336 CHECK_DBL_SAME(rint,( +42.50));
1337 CHECK_DBL_SAME(rint,( +42.75));
1338 CHECK_DBL_SAME(rint,( -42.25));
1339 CHECK_DBL_SAME(rint,( -42.50));
1340 CHECK_DBL_SAME(rint,( -42.75));
1341 CHECK_DBL_SAME(rint,(+1234.60958634e+10));
1342 CHECK_DBL_SAME(rint,(-1234.60958634e+10));
1343 CHECK_DBL_SAME(rint,( -1234.499999e+10));
1344 CHECK_DBL_SAME(rint,( -1234.499999e-10));
1345 CHECK_DBL_SAME(rint,( -2.1984e-310)); /* subnormal */
1346 CHECK_DBL_SAME(rint,(-INFINITY));
1347 CHECK_DBL_SAME(rint,(+INFINITY));
1348 CHECK_DBL_SAME(rint,(RTStrNanDouble(NULL, true)));
1349 CHECK_DBL_SAME(rint,(RTStrNanDouble("s", false)));
1350
1351 CHECK_DBL(RT_NOCRT(rintf)( +0.0f), +0.0f);
1352 CHECK_DBL(RT_NOCRT(rintf)( -0.0f), -0.0f);
1353 CHECK_DBL(RT_NOCRT(rintf)( -42.0f), -42.0f);
1354 CHECK_DBL(RT_NOCRT(rintf)( -42.5f), -42.0f);
1355 CHECK_DBL(RT_NOCRT(rintf)( +42.5f), +42.0f);
1356 CHECK_DBL(RT_NOCRT(rintf)( -43.5f), -43.0f);
1357 CHECK_DBL(RT_NOCRT(rintf)( +43.5f), +43.0f);
1358 CHECK_DBL(RT_NOCRT(rintf)(-42.25f), -42.0f);
1359 CHECK_DBL(RT_NOCRT(rintf)(+42.25f), +42.0f);
1360 CHECK_DBL_SAME(rintf,( -0.0f));
1361 CHECK_DBL_SAME(rintf,( +0.0f));
1362 CHECK_DBL_SAME(rintf,( +42.25f));
1363 CHECK_DBL_SAME(rintf,( +42.50f));
1364 CHECK_DBL_SAME(rintf,( +42.75f));
1365 CHECK_DBL_SAME(rintf,( -42.25f));
1366 CHECK_DBL_SAME(rintf,( -42.50f));
1367 CHECK_DBL_SAME(rintf,( -42.75f));
1368 CHECK_DBL_SAME(rintf,(+1234.60958634e+10f));
1369 CHECK_DBL_SAME(rintf,(-1234.60958634e+10f));
1370 CHECK_DBL_SAME(rintf,( -1234.499999e+10f));
1371 CHECK_DBL_SAME(rintf,( -1234.499999e-10f));
1372 CHECK_DBL_SAME(rintf,( -2.1984e-40f)); /* subnormal */
1373 CHECK_DBL_SAME(rintf,(-INFINITY));
1374 CHECK_DBL_SAME(rintf,(+INFINITY));
1375 CHECK_DBL_SAME(rintf,(RTStrNanFloat(NULL, true)));
1376 CHECK_DBL_SAME(rintf,(RTStrNanFloat("s", false)));
1377
1378 RT_NOCRT(fesetround)(iSavedMode);
1379}
1380
1381
1382void testLRound()
1383{
1384 RTTestSub(g_hTest, "lround[f]");
1385 CHECK_LONG(RT_NOCRT(lround)( +0.0), 0);
1386 CHECK_LONG(RT_NOCRT(lround)( -0.0), 0);
1387 CHECK_LONG(RT_NOCRT(lround)( -42.0), -42);
1388 CHECK_LONG(RT_NOCRT(lround)( -42.5), -43);
1389 CHECK_LONG(RT_NOCRT(lround)( +42.5), +43);
1390 CHECK_LONG(RT_NOCRT(lround)( -42.25), -42);
1391 CHECK_LONG(RT_NOCRT(lround)( +42.25), +42);
1392 CHECK_LONG(RT_NOCRT(lround)(+1234.60958634e+20), LONG_MAX);
1393 CHECK_LONG(RT_NOCRT(lround)(-1234.60958634e+20), LONG_MIN);
1394 CHECK_LONG(RT_NOCRT(lround)( -1234.499999e+20), LONG_MIN);
1395 CHECK_LONG(RT_NOCRT(lround)( -1234.499999e-10), 0);
1396 CHECK_LONG(RT_NOCRT(lround)( -2.1984e-310), 0); /* subnormal */
1397 CHECK_LONG(RT_NOCRT(lround)(-INFINITY), LONG_MIN);
1398 CHECK_LONG(RT_NOCRT(lround)(+INFINITY), LONG_MAX);
1399 CHECK_LONG(RT_NOCRT(lround)(RTStrNanDouble(NULL, true)), LONG_MAX);
1400 CHECK_LONG(RT_NOCRT(lround)(RTStrNanDouble("s", false)), LONG_MAX);
1401 CHECK_LONG_SAME(lround,( -0.0));
1402 CHECK_LONG_SAME(lround,( +0.0));
1403 CHECK_LONG_SAME(lround,( +42.25));
1404 CHECK_LONG_SAME(lround,( +42.25e+6));
1405 CHECK_LONG_SAME(lround,( -42.25e+6));
1406 CHECK_LONG_SAME(lround,( -1234.499999e-10));
1407 CHECK_LONG_SAME(lround,( -2.1984e-310)); /* subnormal */
1408#if 0 /* unspecified, we test our expected behavior above */
1409 CHECK_LONG_SAME(lround,(+1234.60958634e+20));
1410 CHECK_LONG_SAME(lround,(-1234.60958634e+20));
1411 CHECK_LONG_SAME(lround,( -1234.499999e+20));
1412 CHECK_LONG_SAME(lround,(-INFINITY));
1413 CHECK_LONG_SAME(lround,(+INFINITY));
1414 CHECK_LONG_SAME(lround,(RTStrNanDouble(NULL, true)));
1415 CHECK_LONG_SAME(lround,(RTStrNanDouble("s", false)));
1416#endif
1417
1418 CHECK_LONG(RT_NOCRT(lroundf)( +0.0f), 0);
1419 CHECK_LONG(RT_NOCRT(lroundf)( -0.0f), 0);
1420 CHECK_LONG(RT_NOCRT(lroundf)( -42.0f), -42);
1421 CHECK_LONG(RT_NOCRT(lroundf)( -42.5f), -43);
1422 CHECK_LONG(RT_NOCRT(lroundf)( +42.5f), +43);
1423 CHECK_LONG(RT_NOCRT(lroundf)( -42.25f), -42);
1424 CHECK_LONG(RT_NOCRT(lroundf)( +42.25f), +42);
1425 CHECK_LONG(RT_NOCRT(lroundf)(+1234.60958634e+20f), LONG_MAX);
1426 CHECK_LONG(RT_NOCRT(lroundf)(-1234.60958634e+20f), LONG_MIN);
1427 CHECK_LONG(RT_NOCRT(lroundf)( -1234.499999e+20f), LONG_MIN);
1428 CHECK_LONG(RT_NOCRT(lroundf)( -1234.499999e-10f), 0);
1429 CHECK_LONG(RT_NOCRT(lroundf)( -2.1984e-40f), 0); /* subnormal */
1430 CHECK_LONG(RT_NOCRT(lroundf)(-INFINITY), LONG_MIN);
1431 CHECK_LONG(RT_NOCRT(lroundf)(+INFINITY), LONG_MAX);
1432 CHECK_LONG(RT_NOCRT(lroundf)(RTStrNanFloat(NULL, true)), LONG_MAX);
1433 CHECK_LONG(RT_NOCRT(lroundf)(RTStrNanFloat("s", false)), LONG_MAX);
1434 CHECK_LONG_SAME(lroundf,( -0.0f));
1435 CHECK_LONG_SAME(lroundf,( +0.0f));
1436 CHECK_LONG_SAME(lroundf,( +42.25f));
1437 CHECK_LONG_SAME(lroundf,( +42.25e+6f));
1438 CHECK_LONG_SAME(lroundf,( -42.25e+6f));
1439 CHECK_LONG_SAME(lroundf,( -1234.499999e-10f));
1440 CHECK_LONG_SAME(lroundf,( -2.1984e-40f)); /* subnormal */
1441#if 0 /* unspecified, we test our expected behavior above */
1442 CHECK_LONG_SAME(lroundf,(+1234.60958634e+20f));
1443 CHECK_LONG_SAME(lroundf,(-1234.60958634e+20f));
1444 CHECK_LONG_SAME(lroundf,( -1234.499999e+20f));
1445 CHECK_LONG_SAME(lroundf,(-INFINITY));
1446 CHECK_LONG_SAME(lroundf,(+INFINITY));
1447 CHECK_LONG_SAME(lroundf,(RTStrNanFloat(NULL, true)));
1448 CHECK_LONG_SAME(lroundf,(RTStrNanFloat("s", false)));
1449#endif
1450}
1451
1452
1453void testLLRound()
1454{
1455 RTTestSub(g_hTest, "llround[f]");
1456 CHECK_LLONG(RT_NOCRT(llround)( +0.0), 0);
1457 CHECK_LLONG(RT_NOCRT(llround)( -0.0), 0);
1458 CHECK_LLONG(RT_NOCRT(llround)( -42.0), -42);
1459 CHECK_LLONG(RT_NOCRT(llround)( -42.5), -43);
1460 CHECK_LLONG(RT_NOCRT(llround)( +42.5), +43);
1461 CHECK_LLONG(RT_NOCRT(llround)(-42.25), -42);
1462 CHECK_LLONG(RT_NOCRT(llround)(+42.25), +42);
1463 CHECK_LLONG(RT_NOCRT(llround)(+42.25e4), +422500);
1464 CHECK_LLONG(RT_NOCRT(llround)(+42.25e12), +42250000000000LL);
1465 CHECK_LLONG(RT_NOCRT(llround)(+1234.60958634e+20), LLONG_MAX);
1466 CHECK_LLONG(RT_NOCRT(llround)(-1234.60958634e+20), LLONG_MIN);
1467 CHECK_LLONG(RT_NOCRT(llround)( -1234.499999e+20), LLONG_MIN);
1468 CHECK_LLONG(RT_NOCRT(llround)( -1234.499999e-10), 0);
1469 CHECK_LLONG(RT_NOCRT(llround)( -2.1984e-310), 0); /* subnormal */
1470 CHECK_LLONG(RT_NOCRT(llround)(-INFINITY), LLONG_MIN);
1471 CHECK_LLONG(RT_NOCRT(llround)(+INFINITY), LLONG_MAX);
1472 CHECK_LLONG(RT_NOCRT(llround)(RTStrNanDouble(NULL, true)), LLONG_MAX);
1473 CHECK_LLONG(RT_NOCRT(llround)(RTStrNanDouble("s", false)), LLONG_MAX);
1474 CHECK_LLONG_SAME(llround,( -0.0));
1475 CHECK_LLONG_SAME(llround,( +0.0));
1476 CHECK_LLONG_SAME(llround,( +42.25));
1477 CHECK_LLONG_SAME(llround,( +42.25e+6));
1478 CHECK_LLONG_SAME(llround,( -42.25e+6));
1479 CHECK_LLONG_SAME(llround,( -42.25e+12));
1480 CHECK_LLONG_SAME(llround,( +42.265785e+13));
1481 CHECK_LLONG_SAME(llround,( -1234.499999e-10));
1482 CHECK_LLONG_SAME(llround,( -2.1984e-310)); /* subnormal */
1483#if 0 /* unspecified, we test our expected behavior above */
1484 CHECK_LLONG_SAME(llround,(+1234.60958634e+20));
1485 CHECK_LLONG_SAME(llround,(-1234.60958634e+20));
1486 CHECK_LLONG_SAME(llround,( -1234.499999e+20));
1487 CHECK_LLONG_SAME(llround,(-INFINITY));
1488 CHECK_LLONG_SAME(llround,(+INFINITY));
1489 CHECK_LLONG_SAME(llround,(RTStrNanDouble(NULL, true)));
1490 CHECK_LLONG_SAME(llround,(RTStrNanDouble("s", false)));
1491#endif
1492
1493 CHECK_LLONG(RT_NOCRT(llroundf)( +0.0f), 0);
1494 CHECK_LLONG(RT_NOCRT(llroundf)( -0.0f), 0);
1495 CHECK_LLONG(RT_NOCRT(llroundf)( -42.0f), -42);
1496 CHECK_LLONG(RT_NOCRT(llroundf)( -42.5f), -43);
1497 CHECK_LLONG(RT_NOCRT(llroundf)( +42.5f), +43);
1498 CHECK_LLONG(RT_NOCRT(llroundf)(-42.25f), -42);
1499 CHECK_LLONG(RT_NOCRT(llroundf)(+42.25f), +42);
1500 CHECK_LLONG(RT_NOCRT(llroundf)(+42.25e4f), +422500);
1501 CHECK_LLONG(RT_NOCRT(llroundf)(+42.24e10f), +422400000000LL);
1502 CHECK_LLONG(RT_NOCRT(llroundf)(+1234.60958634e+20f), LLONG_MAX);
1503 CHECK_LLONG(RT_NOCRT(llroundf)(-1234.60958634e+20f), LLONG_MIN);
1504 CHECK_LLONG(RT_NOCRT(llroundf)( -1234.499999e+20f), LLONG_MIN);
1505 CHECK_LLONG(RT_NOCRT(llroundf)( -1234.499999e-10f), 0);
1506 CHECK_LLONG(RT_NOCRT(llroundf)( -2.1984e-40f), 0); /* subnormal */
1507 CHECK_LLONG(RT_NOCRT(llroundf)(-INFINITY), LLONG_MIN);
1508 CHECK_LLONG(RT_NOCRT(llroundf)(+INFINITY), LLONG_MAX);
1509 CHECK_LLONG(RT_NOCRT(llroundf)(RTStrNanFloat(NULL, true)), LLONG_MAX);
1510 CHECK_LLONG(RT_NOCRT(llroundf)(RTStrNanFloat("s", false)), LLONG_MAX);
1511 CHECK_LLONG_SAME(llroundf,( -0.0f));
1512 CHECK_LLONG_SAME(llroundf,( +0.0f));
1513 CHECK_LLONG_SAME(llroundf,( +42.25f));
1514 CHECK_LLONG_SAME(llroundf,( +42.25e+6f));
1515 CHECK_LLONG_SAME(llroundf,( -42.25e+6f));
1516 CHECK_LLONG_SAME(llroundf,( -42.25e+12f));
1517 CHECK_LLONG_SAME(llroundf,( +42.265785e+13f));
1518 CHECK_LLONG_SAME(llroundf,( -1234.499999e-10f));
1519 CHECK_LLONG_SAME(llroundf,( -2.1984e-40f)); /* subnormal */
1520#if 0 /* unspecified, we test our expected behavior above */
1521 CHECK_LLONG_SAME(llroundf,(+1234.60958634e+20f));
1522 CHECK_LLONG_SAME(llroundf,(-1234.60958634e+20f));
1523 CHECK_LLONG_SAME(llroundf,( -1234.499999e+20f));
1524 CHECK_LLONG_SAME(llroundf,(-INFINITY));
1525 CHECK_LLONG_SAME(llroundf,(+INFINITY));
1526 CHECK_LLONG_SAME(llroundf,(RTStrNanFloat(NULL, true)));
1527 CHECK_LLONG_SAME(llroundf,(RTStrNanFloat("s", false)));
1528#endif
1529
1530#if 0
1531 CHECK_LLONG(RT_NOCRT(llroundl)( +0.0L), 0);
1532 CHECK_LLONG(RT_NOCRT(llroundl)( -0.0L), 0);
1533 CHECK_LLONG(RT_NOCRT(llroundl)( -42.0L), -42);
1534 CHECK_LLONG(RT_NOCRT(llroundl)( -42.5L), -43);
1535 CHECK_LLONG(RT_NOCRT(llroundl)( +42.5L), +43);
1536 CHECK_LLONG(RT_NOCRT(llroundl)(-42.25L), -42);
1537 CHECK_LLONG(RT_NOCRT(llroundl)(+42.25L), +42);
1538 CHECK_LLONG(RT_NOCRT(llroundl)(+42.25e4L), +422500);
1539 CHECK_LLONG(RT_NOCRT(llroundl)(+42.24e12L), +42240000000000LL);
1540 CHECK_LLONG(RT_NOCRT(llroundl)(+1234.60958634e+20L), LLONG_MAX);
1541 CHECK_LLONG(RT_NOCRT(llroundl)(-1234.60958634e+20L), LLONG_MIN);
1542 CHECK_LLONG(RT_NOCRT(llroundl)( -1234.499999e+20L), LLONG_MIN);
1543 CHECK_LLONG(RT_NOCRT(llroundl)( -1234.499999e-10L), 0);
1544#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
1545 CHECK_LLONG(RT_NOCRT(llroundl)( -2.1984e-310L), 0); /* subnormal */
1546#else
1547 CHECK_LLONG(RT_NOCRT(llroundl)( -2.1984e-4935L), 0); /* subnormal */
1548#endif
1549 CHECK_LLONG(RT_NOCRT(llroundl)(-INFINITY), LLONG_MIN);
1550 CHECK_LLONG(RT_NOCRT(llroundl)(+INFINITY), LLONG_MAX);
1551 CHECK_LLONG(RT_NOCRT(llroundl)(RTStrNanLongDouble(NULL, true)), LLONG_MAX);
1552 CHECK_LLONG(RT_NOCRT(llroundl)(RTStrNanLongDouble("s", false)), LLONG_MAX);
1553 CHECK_LLONG_SAME(llroundl,( -0.0));
1554 CHECK_LLONG_SAME(llroundl,( +0.0));
1555 CHECK_LLONG_SAME(llroundl,( +42.25));
1556 CHECK_LLONG_SAME(llroundl,( +42.25e+6));
1557 CHECK_LLONG_SAME(llroundl,( -42.25e+6));
1558 CHECK_LLONG_SAME(llroundl,( -42.25e+12));
1559 CHECK_LLONG_SAME(llroundl,( +42.265785e+13));
1560 CHECK_LLONG_SAME(llroundl,( -1234.499999e-10L));
1561# ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
1562 CHECK_LLONG_SAME(llroundl,( -2.1984e-310L)); /* subnormal */
1563# else
1564 CHECK_LLONG_SAME(llroundl,( -2.1984e-4935L)); /* subnormal */
1565# endif
1566#if 0 /* unspecified, we test our expected behavior above */
1567 CHECK_LLONG_SAME(llroundl,(+1234.60958634e+20L));
1568 CHECK_LLONG_SAME(llroundl,(-1234.60958634e+20L));
1569 CHECK_LLONG_SAME(llroundl,( -1234.499999e+20L));
1570 CHECK_LLONG_SAME(llroundl,(-INFINITY));
1571 CHECK_LLONG_SAME(llroundl,(+INFINITY));
1572 CHECK_LLONG_SAME(llroundl,(RTStrNanLongDouble(NULL, true)));
1573 CHECK_LLONG_SAME(llroundl,(RTStrNanLongDouble("s", false)));
1574#endif
1575#endif
1576}
1577
1578
1579void testLRInt()
1580{
1581 RTTestSub(g_hTest, "lrint[f]");
1582
1583 /*
1584 * Round nearest.
1585 */
1586 int const iSavedMode = RT_NOCRT(fegetround)();
1587 if (iSavedMode != FE_TONEAREST)
1588 RTTestFailed(g_hTest, "expected FE_TONEAREST as default rounding mode, not %#x (%d)", iSavedMode, iSavedMode);
1589 RT_NOCRT(fesetround)(FE_TONEAREST);
1590
1591 CHECK_LONG(RT_NOCRT(lrint)( +0.0), 0);
1592 CHECK_LONG(RT_NOCRT(lrint)( -0.0), 0);
1593 CHECK_LONG(RT_NOCRT(lrint)( -42.0), -42);
1594 CHECK_LONG(RT_NOCRT(lrint)( -42.5), -42);
1595 CHECK_LONG(RT_NOCRT(lrint)( +42.5), +42);
1596 CHECK_LONG(RT_NOCRT(lrint)( -43.5), -44);
1597 CHECK_LONG(RT_NOCRT(lrint)( +43.5), +44);
1598 CHECK_LONG(RT_NOCRT(lrint)( -42.25), -42);
1599 CHECK_LONG(RT_NOCRT(lrint)( +42.25), +42);
1600 CHECK_LONG(RT_NOCRT(lrint)( -42.75), -43);
1601 CHECK_LONG(RT_NOCRT(lrint)( +42.75), +43);
1602 CHECK_LONG(RT_NOCRT(lrint)(+1234.60958634e+20), LONG_MIN);
1603 CHECK_LONG(RT_NOCRT(lrint)(-1234.60958634e+20), LONG_MIN);
1604 CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e+20), LONG_MIN);
1605 CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e-10), 0);
1606 CHECK_LONG(RT_NOCRT(lrint)( -2.1984e-310), 0); /* subnormal */
1607 CHECK_LONG(RT_NOCRT(lrint)(-INFINITY), LONG_MIN);
1608 CHECK_LONG(RT_NOCRT(lrint)(+INFINITY), LONG_MIN);
1609 CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble(NULL, true)), LONG_MIN);
1610 CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble("s", false)), LONG_MIN);
1611 CHECK_LONG_SAME(lrint,( -0.0));
1612 CHECK_LONG_SAME(lrint,( +0.0));
1613 CHECK_LONG_SAME(lrint,( +42.25));
1614 CHECK_LONG_SAME(lrint,( -42.25));
1615 CHECK_LONG_SAME(lrint,( +42.75));
1616 CHECK_LONG_SAME(lrint,( -42.75));
1617 CHECK_LONG_SAME(lrint,( +22.5));
1618 CHECK_LONG_SAME(lrint,( -22.5));
1619 CHECK_LONG_SAME(lrint,( +23.5));
1620 CHECK_LONG_SAME(lrint,( -23.5));
1621 CHECK_LONG_SAME(lrint,( +42.25e+6));
1622 CHECK_LONG_SAME(lrint,( -42.25e+6));
1623 CHECK_LONG_SAME(lrint,( -1234.499999e-10));
1624 CHECK_LONG_SAME(lrint,( -2.1984e-310)); /* subnormal */
1625#if 0 /* Undefined, we disagree with UCRT on windows. */
1626 CHECK_LONG_SAME(lrint,(+1234.60958634e+20));
1627 CHECK_LONG_SAME(lrint,(-1234.60958634e+20));
1628 CHECK_LONG_SAME(lrint,( -1234.499999e+20));
1629 CHECK_LONG_SAME(lrint,(-INFINITY));
1630 CHECK_LONG_SAME(lrint,(+INFINITY));
1631 CHECK_LONG_SAME(lrint,(RTStrNanDouble(NULL, true)));
1632 CHECK_LONG_SAME(lrint,(RTStrNanDouble("s", false)));
1633#endif
1634
1635 CHECK_LONG(RT_NOCRT(lrintf)( +0.0f), 0);
1636 CHECK_LONG(RT_NOCRT(lrintf)( -0.0f), 0);
1637 CHECK_LONG(RT_NOCRT(lrintf)( -42.0f), -42);
1638 CHECK_LONG(RT_NOCRT(lrintf)( -42.5f), -42);
1639 CHECK_LONG(RT_NOCRT(lrintf)( +42.5f), +42);
1640 CHECK_LONG(RT_NOCRT(lrintf)( -43.5f), -44);
1641 CHECK_LONG(RT_NOCRT(lrintf)( +43.5f), +44);
1642 CHECK_LONG(RT_NOCRT(lrintf)( -42.25f), -42);
1643 CHECK_LONG(RT_NOCRT(lrintf)( +42.25f), +42);
1644 CHECK_LONG(RT_NOCRT(lrintf)( -42.75f), -43);
1645 CHECK_LONG(RT_NOCRT(lrintf)( +42.75f), +43);
1646 CHECK_LONG(RT_NOCRT(lrintf)(+1234.60958634e+20f), LONG_MIN);
1647 CHECK_LONG(RT_NOCRT(lrintf)(-1234.60958634e+20f), LONG_MIN);
1648 CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e+20f), LONG_MIN);
1649 CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e-10f), 0);
1650 CHECK_LONG(RT_NOCRT(lrintf)( -2.1984e-40f), 0); /* subnormal */
1651 CHECK_LONG(RT_NOCRT(lrintf)(-INFINITY), LONG_MIN);
1652 CHECK_LONG(RT_NOCRT(lrintf)(+INFINITY), LONG_MIN);
1653 CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble(NULL, true)), LONG_MIN);
1654 CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble("s", false)), LONG_MIN);
1655 CHECK_LONG_SAME(lrintf,( -0.0f));
1656 CHECK_LONG_SAME(lrintf,( +0.0f));
1657 CHECK_LONG_SAME(lrintf,( +42.25f));
1658 CHECK_LONG_SAME(lrintf,( -42.25f));
1659 CHECK_LONG_SAME(lrintf,( +42.75f));
1660 CHECK_LONG_SAME(lrintf,( -42.75f));
1661 CHECK_LONG_SAME(lrintf,( +22.5f));
1662 CHECK_LONG_SAME(lrintf,( -22.5f));
1663 CHECK_LONG_SAME(lrintf,( +23.5f));
1664 CHECK_LONG_SAME(lrintf,( -23.5f));
1665 CHECK_LONG_SAME(lrintf,( +42.25e+6f));
1666 CHECK_LONG_SAME(lrintf,( -42.25e+6f));
1667 CHECK_LONG_SAME(lrintf,( -1234.499999e-10f));
1668 CHECK_LONG_SAME(lrintf,( -2.1984e-40f)); /* subnormal */
1669#if 0 /* Undefined, we disagree with UCRT on windows. */
1670 CHECK_LONG_SAME(lrintf,(+1234.60958634e+20f));
1671 CHECK_LONG_SAME(lrintf,(-1234.60958634e+20f));
1672 CHECK_LONG_SAME(lrintf,( -1234.499999e+20f));
1673 CHECK_LONG_SAME(lrintf,(-INFINITY));
1674 CHECK_LONG_SAME(lrintf,(+INFINITY));
1675 CHECK_LONG_SAME(lrintf,(RTStrNanFloat(NULL, true)));
1676 CHECK_LONG_SAME(lrintf,(RTStrNanFloat("s", false)));
1677#endif
1678
1679 /*
1680 * Round UP.
1681 */
1682 RT_NOCRT(fesetround)(FE_UPWARD);
1683
1684 CHECK_LONG(RT_NOCRT(lrint)( +0.0), 0);
1685 CHECK_LONG(RT_NOCRT(lrint)( -0.0), 0);
1686 CHECK_LONG(RT_NOCRT(lrint)( -42.0), -42);
1687 CHECK_LONG(RT_NOCRT(lrint)( -42.5), -42);
1688 CHECK_LONG(RT_NOCRT(lrint)( +42.5), +43);
1689 CHECK_LONG(RT_NOCRT(lrint)( -43.5), -43);
1690 CHECK_LONG(RT_NOCRT(lrint)( +43.5), +44);
1691 CHECK_LONG(RT_NOCRT(lrint)( -42.25), -42);
1692 CHECK_LONG(RT_NOCRT(lrint)( +42.25), +43);
1693 CHECK_LONG(RT_NOCRT(lrint)( -42.75), -42);
1694 CHECK_LONG(RT_NOCRT(lrint)( +42.75), +43);
1695 CHECK_LONG(RT_NOCRT(lrint)(+1234.60958634e+20), LONG_MIN);
1696 CHECK_LONG(RT_NOCRT(lrint)(-1234.60958634e+20), LONG_MIN);
1697 CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e+20), LONG_MIN);
1698 CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e-10), 0);
1699 CHECK_LONG(RT_NOCRT(lrint)( -2.1984e-310), 0); /* subnormal */
1700 CHECK_LONG(RT_NOCRT(lrint)(-INFINITY), LONG_MIN);
1701 CHECK_LONG(RT_NOCRT(lrint)(+INFINITY), LONG_MIN);
1702 CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble(NULL, true)), LONG_MIN);
1703 CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble("s", false)), LONG_MIN);
1704 CHECK_LONG_SAME(lrint,( -0.0));
1705 CHECK_LONG_SAME(lrint,( +0.0));
1706 CHECK_LONG_SAME(lrint,( +42.25));
1707 CHECK_LONG_SAME(lrint,( -42.25));
1708 CHECK_LONG_SAME(lrint,( +42.75));
1709 CHECK_LONG_SAME(lrint,( -42.75));
1710 CHECK_LONG_SAME(lrint,( +22.5));
1711 CHECK_LONG_SAME(lrint,( -22.5));
1712 CHECK_LONG_SAME(lrint,( +23.5));
1713 CHECK_LONG_SAME(lrint,( -23.5));
1714 CHECK_LONG_SAME(lrint,( +42.25e+6));
1715 CHECK_LONG_SAME(lrint,( -42.25e+6));
1716 CHECK_LONG_SAME(lrint,( -1234.499999e-10));
1717 CHECK_LONG_SAME(lrint,( -2.1984e-310)); /* subnormal */
1718#if 0 /* Undefined, we disagree with UCRT on windows. */
1719 CHECK_LONG_SAME(lrint,(+1234.60958634e+20));
1720 CHECK_LONG_SAME(lrint,(-1234.60958634e+20));
1721 CHECK_LONG_SAME(lrint,( -1234.499999e+20));
1722 CHECK_LONG_SAME(lrint,(-INFINITY));
1723 CHECK_LONG_SAME(lrint,(+INFINITY));
1724 CHECK_LONG_SAME(lrint,(RTStrNanDouble(NULL, true)));
1725 CHECK_LONG_SAME(lrint,(RTStrNanDouble("s", false)));
1726#endif
1727
1728 CHECK_LONG(RT_NOCRT(lrintf)( +0.0f), 0);
1729 CHECK_LONG(RT_NOCRT(lrintf)( -0.0f), 0);
1730 CHECK_LONG(RT_NOCRT(lrintf)( -42.0f), -42);
1731 CHECK_LONG(RT_NOCRT(lrintf)( -42.5f), -42);
1732 CHECK_LONG(RT_NOCRT(lrintf)( +42.5f), +43);
1733 CHECK_LONG(RT_NOCRT(lrintf)( -43.5f), -43);
1734 CHECK_LONG(RT_NOCRT(lrintf)( +43.5f), +44);
1735 CHECK_LONG(RT_NOCRT(lrintf)( -42.25f), -42);
1736 CHECK_LONG(RT_NOCRT(lrintf)( +42.25f), +43);
1737 CHECK_LONG(RT_NOCRT(lrintf)( -42.75f), -42);
1738 CHECK_LONG(RT_NOCRT(lrintf)( +42.75f), +43);
1739 CHECK_LONG(RT_NOCRT(lrintf)(+1234.60958634e+20f), LONG_MIN);
1740 CHECK_LONG(RT_NOCRT(lrintf)(-1234.60958634e+20f), LONG_MIN);
1741 CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e+20f), LONG_MIN);
1742 CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e-10f), 0);
1743 CHECK_LONG(RT_NOCRT(lrintf)( -2.1984e-40f), 0); /* subnormal */
1744 CHECK_LONG(RT_NOCRT(lrintf)(-INFINITY), LONG_MIN);
1745 CHECK_LONG(RT_NOCRT(lrintf)(+INFINITY), LONG_MIN);
1746 CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble(NULL, true)), LONG_MIN);
1747 CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble("s", false)), LONG_MIN);
1748 CHECK_LONG_SAME(lrintf,( -0.0f));
1749 CHECK_LONG_SAME(lrintf,( +0.0f));
1750 CHECK_LONG_SAME(lrintf,( +42.25f));
1751 CHECK_LONG_SAME(lrintf,( -42.25f));
1752 CHECK_LONG_SAME(lrintf,( +42.75f));
1753 CHECK_LONG_SAME(lrintf,( -42.75f));
1754 CHECK_LONG_SAME(lrintf,( +22.5f));
1755 CHECK_LONG_SAME(lrintf,( -22.5f));
1756 CHECK_LONG_SAME(lrintf,( +23.5f));
1757 CHECK_LONG_SAME(lrintf,( -23.5f));
1758 CHECK_LONG_SAME(lrintf,( +42.25e+6f));
1759 CHECK_LONG_SAME(lrintf,( -42.25e+6f));
1760 CHECK_LONG_SAME(lrintf,( -1234.499999e-10f));
1761 CHECK_LONG_SAME(lrintf,( -2.1984e-40f)); /* subnormal */
1762#if 0 /* Undefined, we disagree with UCRT on windows. */
1763 CHECK_LONG_SAME(lrintf,(+1234.60958634e+20f));
1764 CHECK_LONG_SAME(lrintf,(-1234.60958634e+20f));
1765 CHECK_LONG_SAME(lrintf,( -1234.499999e+20f));
1766 CHECK_LONG_SAME(lrintf,(-INFINITY));
1767 CHECK_LONG_SAME(lrintf,(+INFINITY));
1768 CHECK_LONG_SAME(lrintf,(RTStrNanFloat(NULL, true)));
1769 CHECK_LONG_SAME(lrintf,(RTStrNanFloat("s", false)));
1770#endif
1771
1772 /*
1773 * Round DOWN.
1774 */
1775 RT_NOCRT(fesetround)(FE_DOWNWARD);
1776
1777 CHECK_LONG(RT_NOCRT(lrint)( +0.0), 0);
1778 CHECK_LONG(RT_NOCRT(lrint)( -0.0), 0);
1779 CHECK_LONG(RT_NOCRT(lrint)( -42.0), -42);
1780 CHECK_LONG(RT_NOCRT(lrint)( -42.5), -43);
1781 CHECK_LONG(RT_NOCRT(lrint)( +42.5), +42);
1782 CHECK_LONG(RT_NOCRT(lrint)( -43.5), -44);
1783 CHECK_LONG(RT_NOCRT(lrint)( +43.5), +43);
1784 CHECK_LONG(RT_NOCRT(lrint)( -42.25), -43);
1785 CHECK_LONG(RT_NOCRT(lrint)( +42.25), +42);
1786 CHECK_LONG(RT_NOCRT(lrint)( -42.75), -43);
1787 CHECK_LONG(RT_NOCRT(lrint)( +42.75), +42);
1788 CHECK_LONG(RT_NOCRT(lrint)(+1234.60958634e+20), LONG_MIN);
1789 CHECK_LONG(RT_NOCRT(lrint)(-1234.60958634e+20), LONG_MIN);
1790 CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e+20), LONG_MIN);
1791 CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e-10), -1);
1792 CHECK_LONG(RT_NOCRT(lrint)( -2.1984e-310), -1); /* subnormal */
1793 CHECK_LONG(RT_NOCRT(lrint)(-INFINITY), LONG_MIN);
1794 CHECK_LONG(RT_NOCRT(lrint)(+INFINITY), LONG_MIN);
1795 CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble(NULL, true)), LONG_MIN);
1796 CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble("s", false)), LONG_MIN);
1797 CHECK_LONG_SAME(lrint,( -0.0));
1798 CHECK_LONG_SAME(lrint,( +0.0));
1799 CHECK_LONG_SAME(lrint,( +42.25));
1800 CHECK_LONG_SAME(lrint,( -42.25));
1801 CHECK_LONG_SAME(lrint,( +42.75));
1802 CHECK_LONG_SAME(lrint,( -42.75));
1803 CHECK_LONG_SAME(lrint,( +22.5));
1804 CHECK_LONG_SAME(lrint,( -22.5));
1805 CHECK_LONG_SAME(lrint,( +23.5));
1806 CHECK_LONG_SAME(lrint,( -23.5));
1807 CHECK_LONG_SAME(lrint,( +42.25e+6));
1808 CHECK_LONG_SAME(lrint,( -42.25e+6));
1809 CHECK_LONG_SAME(lrint,( -1234.499999e-10));
1810 CHECK_LONG_SAME(lrint,( -2.1984e-310)); /* subnormal */
1811#if 0 /* Undefined, we disagree with UCRT on windows. */
1812 CHECK_LONG_SAME(lrint,(+1234.60958634e+20));
1813 CHECK_LONG_SAME(lrint,(-1234.60958634e+20));
1814 CHECK_LONG_SAME(lrint,( -1234.499999e+20));
1815 CHECK_LONG_SAME(lrint,(-INFINITY));
1816 CHECK_LONG_SAME(lrint,(+INFINITY));
1817 CHECK_LONG_SAME(lrint,(RTStrNanDouble(NULL, true)));
1818 CHECK_LONG_SAME(lrint,(RTStrNanDouble("s", false)));
1819#endif
1820
1821 CHECK_LONG(RT_NOCRT(lrintf)( +0.0f), 0);
1822 CHECK_LONG(RT_NOCRT(lrintf)( -0.0f), 0);
1823 CHECK_LONG(RT_NOCRT(lrintf)( -42.0f), -42);
1824 CHECK_LONG(RT_NOCRT(lrintf)( -42.5f), -43);
1825 CHECK_LONG(RT_NOCRT(lrintf)( +42.5f), +42);
1826 CHECK_LONG(RT_NOCRT(lrintf)( -43.5f), -44);
1827 CHECK_LONG(RT_NOCRT(lrintf)( +43.5f), +43);
1828 CHECK_LONG(RT_NOCRT(lrintf)( -42.25f), -43);
1829 CHECK_LONG(RT_NOCRT(lrintf)( +42.25f), +42);
1830 CHECK_LONG(RT_NOCRT(lrintf)( -42.75f), -43);
1831 CHECK_LONG(RT_NOCRT(lrintf)( +42.75f), +42);
1832 CHECK_LONG(RT_NOCRT(lrintf)(+1234.60958634e+20f), LONG_MIN);
1833 CHECK_LONG(RT_NOCRT(lrintf)(-1234.60958634e+20f), LONG_MIN);
1834 CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e+20f), LONG_MIN);
1835 CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e-10f), -1);
1836 CHECK_LONG(RT_NOCRT(lrintf)( -2.1984e-40f), -1); /* subnormal */
1837 CHECK_LONG(RT_NOCRT(lrintf)(-INFINITY), LONG_MIN);
1838 CHECK_LONG(RT_NOCRT(lrintf)(+INFINITY), LONG_MIN);
1839 CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble(NULL, true)), LONG_MIN);
1840 CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble("s", false)), LONG_MIN);
1841 CHECK_LONG_SAME(lrintf,( -0.0f));
1842 CHECK_LONG_SAME(lrintf,( +0.0f));
1843 CHECK_LONG_SAME(lrintf,( +42.25f));
1844 CHECK_LONG_SAME(lrintf,( -42.25f));
1845 CHECK_LONG_SAME(lrintf,( +42.75f));
1846 CHECK_LONG_SAME(lrintf,( -42.75f));
1847 CHECK_LONG_SAME(lrintf,( +22.5f));
1848 CHECK_LONG_SAME(lrintf,( -22.5f));
1849 CHECK_LONG_SAME(lrintf,( +23.5f));
1850 CHECK_LONG_SAME(lrintf,( -23.5f));
1851 CHECK_LONG_SAME(lrintf,( +42.25e+6f));
1852 CHECK_LONG_SAME(lrintf,( -42.25e+6f));
1853 CHECK_LONG_SAME(lrintf,( -1234.499999e-10f));
1854 CHECK_LONG_SAME(lrintf,( -2.1984e-40f)); /* subnormal */
1855#if 0 /* Undefined, we disagree with UCRT on windows. */
1856 CHECK_LONG_SAME(lrintf,(+1234.60958634e+20f));
1857 CHECK_LONG_SAME(lrintf,(-1234.60958634e+20f));
1858 CHECK_LONG_SAME(lrintf,( -1234.499999e+20f));
1859 CHECK_LONG_SAME(lrintf,(-INFINITY));
1860 CHECK_LONG_SAME(lrintf,(+INFINITY));
1861 CHECK_LONG_SAME(lrintf,(RTStrNanFloat(NULL, true)));
1862 CHECK_LONG_SAME(lrintf,(RTStrNanFloat("s", false)));
1863#endif
1864
1865 /*
1866 * Round towards ZERO.
1867 */
1868 RT_NOCRT(fesetround)(FE_TOWARDZERO);
1869
1870 CHECK_LONG(RT_NOCRT(lrint)( +0.0), 0);
1871 CHECK_LONG(RT_NOCRT(lrint)( -0.0), 0);
1872 CHECK_LONG(RT_NOCRT(lrint)( -42.0), -42);
1873 CHECK_LONG(RT_NOCRT(lrint)( -42.5), -42);
1874 CHECK_LONG(RT_NOCRT(lrint)( +42.5), +42);
1875 CHECK_LONG(RT_NOCRT(lrint)( -43.5), -43);
1876 CHECK_LONG(RT_NOCRT(lrint)( +43.5), +43);
1877 CHECK_LONG(RT_NOCRT(lrint)( -42.25), -42);
1878 CHECK_LONG(RT_NOCRT(lrint)( +42.25), +42);
1879 CHECK_LONG(RT_NOCRT(lrint)( -42.75), -42);
1880 CHECK_LONG(RT_NOCRT(lrint)( +42.75), +42);
1881 CHECK_LONG(RT_NOCRT(lrint)(+1234.60958634e+20), LONG_MIN);
1882 CHECK_LONG(RT_NOCRT(lrint)(-1234.60958634e+20), LONG_MIN);
1883 CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e+20), LONG_MIN);
1884 CHECK_LONG(RT_NOCRT(lrint)( -1234.499999e-10), 0);
1885 CHECK_LONG(RT_NOCRT(lrint)( -2.1984e-310), 0); /* subnormal */
1886 CHECK_LONG(RT_NOCRT(lrint)(-INFINITY), LONG_MIN);
1887 CHECK_LONG(RT_NOCRT(lrint)(+INFINITY), LONG_MIN);
1888 CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble(NULL, true)), LONG_MIN);
1889 CHECK_LONG(RT_NOCRT(lrint)(RTStrNanDouble("s", false)), LONG_MIN);
1890 CHECK_LONG_SAME(lrint,( -0.0));
1891 CHECK_LONG_SAME(lrint,( +0.0));
1892 CHECK_LONG_SAME(lrint,( +42.25));
1893 CHECK_LONG_SAME(lrint,( -42.25));
1894 CHECK_LONG_SAME(lrint,( +42.75));
1895 CHECK_LONG_SAME(lrint,( -42.75));
1896 CHECK_LONG_SAME(lrint,( +22.5));
1897 CHECK_LONG_SAME(lrint,( -22.5));
1898 CHECK_LONG_SAME(lrint,( +23.5));
1899 CHECK_LONG_SAME(lrint,( -23.5));
1900 CHECK_LONG_SAME(lrint,( +42.25e+6));
1901 CHECK_LONG_SAME(lrint,( -42.25e+6));
1902 CHECK_LONG_SAME(lrint,( -1234.499999e-10));
1903 CHECK_LONG_SAME(lrint,( -2.1984e-310)); /* subnormal */
1904#if 0 /* Undefined, we disagree with UCRT on windows. */
1905 CHECK_LONG_SAME(lrint,(+1234.60958634e+20));
1906 CHECK_LONG_SAME(lrint,(-1234.60958634e+20));
1907 CHECK_LONG_SAME(lrint,( -1234.499999e+20));
1908 CHECK_LONG_SAME(lrint,(-INFINITY));
1909 CHECK_LONG_SAME(lrint,(+INFINITY));
1910 CHECK_LONG_SAME(lrint,(RTStrNanDouble(NULL, true)));
1911 CHECK_LONG_SAME(lrint,(RTStrNanDouble("s", false)));
1912#endif
1913
1914 CHECK_LONG(RT_NOCRT(lrintf)( +0.0f), 0);
1915 CHECK_LONG(RT_NOCRT(lrintf)( -0.0f), 0);
1916 CHECK_LONG(RT_NOCRT(lrintf)( -42.0f), -42);
1917 CHECK_LONG(RT_NOCRT(lrintf)( -42.5f), -42);
1918 CHECK_LONG(RT_NOCRT(lrintf)( +42.5f), +42);
1919 CHECK_LONG(RT_NOCRT(lrintf)( -43.5f), -43);
1920 CHECK_LONG(RT_NOCRT(lrintf)( +43.5f), +43);
1921 CHECK_LONG(RT_NOCRT(lrintf)( -42.25f), -42);
1922 CHECK_LONG(RT_NOCRT(lrintf)( +42.25f), +42);
1923 CHECK_LONG(RT_NOCRT(lrintf)( -42.75f), -42);
1924 CHECK_LONG(RT_NOCRT(lrintf)( +42.75f), +42);
1925 CHECK_LONG(RT_NOCRT(lrintf)(+1234.60958634e+20f), LONG_MIN);
1926 CHECK_LONG(RT_NOCRT(lrintf)(-1234.60958634e+20f), LONG_MIN);
1927 CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e+20f), LONG_MIN);
1928 CHECK_LONG(RT_NOCRT(lrintf)( -1234.499999e-10f), 0);
1929 CHECK_LONG(RT_NOCRT(lrintf)( -2.1984e-40f), 0); /* subnormal */
1930 CHECK_LONG(RT_NOCRT(lrintf)(-INFINITY), LONG_MIN);
1931 CHECK_LONG(RT_NOCRT(lrintf)(+INFINITY), LONG_MIN);
1932 CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble(NULL, true)), LONG_MIN);
1933 CHECK_LONG(RT_NOCRT(lrintf)(RTStrNanDouble("s", false)), LONG_MIN);
1934 CHECK_LONG_SAME(lrintf,( -0.0f));
1935 CHECK_LONG_SAME(lrintf,( +0.0f));
1936 CHECK_LONG_SAME(lrintf,( +42.25f));
1937 CHECK_LONG_SAME(lrintf,( -42.25f));
1938 CHECK_LONG_SAME(lrintf,( +42.75f));
1939 CHECK_LONG_SAME(lrintf,( -42.75f));
1940 CHECK_LONG_SAME(lrintf,( +22.5f));
1941 CHECK_LONG_SAME(lrintf,( -22.5f));
1942 CHECK_LONG_SAME(lrintf,( +23.5f));
1943 CHECK_LONG_SAME(lrintf,( -23.5f));
1944 CHECK_LONG_SAME(lrintf,( +42.25e+6f));
1945 CHECK_LONG_SAME(lrintf,( -42.25e+6f));
1946 CHECK_LONG_SAME(lrintf,( -1234.499999e-10f));
1947 CHECK_LONG_SAME(lrintf,( -2.1984e-40f)); /* subnormal */
1948#if 0 /* Undefined, we disagree with UCRT on windows. */
1949 CHECK_LONG_SAME(lrintf,(+1234.60958634e+20f));
1950 CHECK_LONG_SAME(lrintf,(-1234.60958634e+20f));
1951 CHECK_LONG_SAME(lrintf,( -1234.499999e+20f));
1952 CHECK_LONG_SAME(lrintf,(-INFINITY));
1953 CHECK_LONG_SAME(lrintf,(+INFINITY));
1954 CHECK_LONG_SAME(lrintf,(RTStrNanFloat(NULL, true)));
1955 CHECK_LONG_SAME(lrintf,(RTStrNanFloat("s", false)));
1956#endif
1957
1958 RT_NOCRT(fesetround)(iSavedMode);
1959}
1960
1961
1962void testLLRInt()
1963{
1964 RTTestSub(g_hTest, "llrint[f]");
1965
1966 /*
1967 * Round nearest.
1968 */
1969 int const iSavedMode = RT_NOCRT(fegetround)();
1970 if (iSavedMode != FE_TONEAREST)
1971 RTTestFailed(g_hTest, "expected FE_TONEAREST as default rounding mode, not %#x (%d)", iSavedMode, iSavedMode);
1972 RT_NOCRT(fesetround)(FE_TONEAREST);
1973
1974 CHECK_LLONG(RT_NOCRT(llrint)( +0.0), 0);
1975 CHECK_LLONG(RT_NOCRT(llrint)( -0.0), 0);
1976 CHECK_LLONG(RT_NOCRT(llrint)( -42.0), -42);
1977 CHECK_LLONG(RT_NOCRT(llrint)( -42.5), -42);
1978 CHECK_LLONG(RT_NOCRT(llrint)( +42.5), +42);
1979 CHECK_LLONG(RT_NOCRT(llrint)( -43.5), -44);
1980 CHECK_LLONG(RT_NOCRT(llrint)( +43.5), +44);
1981 CHECK_LLONG(RT_NOCRT(llrint)( -42.25), -42);
1982 CHECK_LLONG(RT_NOCRT(llrint)( +42.25), +42);
1983 CHECK_LLONG(RT_NOCRT(llrint)( -42.75), -43);
1984 CHECK_LLONG(RT_NOCRT(llrint)( +42.75), +43);
1985 CHECK_LLONG(RT_NOCRT(llrint)(+1234.60958634e+20), LLONG_MIN);
1986 CHECK_LLONG(RT_NOCRT(llrint)(-1234.60958634e+20), LLONG_MIN);
1987 CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e+20), LLONG_MIN);
1988 CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e-10), 0);
1989 CHECK_LLONG(RT_NOCRT(llrint)( -2.1984e-310), 0); /* subnormal */
1990 CHECK_LLONG(RT_NOCRT(llrint)(-INFINITY), LLONG_MIN);
1991 CHECK_LLONG(RT_NOCRT(llrint)(+INFINITY), LLONG_MIN);
1992 CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble(NULL, true)),LLONG_MIN);
1993 CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble("s", false)),LLONG_MIN);
1994 CHECK_LLONG_SAME(llrint,( -0.0));
1995 CHECK_LLONG_SAME(llrint,( +0.0));
1996 CHECK_LLONG_SAME(llrint,( +42.25));
1997 CHECK_LLONG_SAME(llrint,( -42.25));
1998 CHECK_LLONG_SAME(llrint,( +42.75));
1999 CHECK_LLONG_SAME(llrint,( -42.75));
2000 CHECK_LLONG_SAME(llrint,( +22.5));
2001 CHECK_LLONG_SAME(llrint,( -22.5));
2002 CHECK_LLONG_SAME(llrint,( +23.5));
2003 CHECK_LLONG_SAME(llrint,( -23.5));
2004 CHECK_LLONG_SAME(llrint,( +42.25e+6));
2005 CHECK_LLONG_SAME(llrint,( -42.25e+6));
2006 CHECK_LLONG_SAME(llrint,( -1234.499999e-10));
2007 CHECK_LLONG_SAME(llrint,( -2.1984e-310)); /* subnormal */
2008#if 0 /* Undefined, we disagree with UCRT on windows. */
2009 CHECK_LLONG_SAME(llrint,(+1234.60958634e+20));
2010 CHECK_LLONG_SAME(llrint,(-1234.60958634e+20));
2011 CHECK_LLONG_SAME(llrint,( -1234.499999e+20));
2012 CHECK_LLONG_SAME(llrint,(-INFINITY));
2013 CHECK_LLONG_SAME(llrint,(+INFINITY));
2014 CHECK_LLONG_SAME(llrint,(RTStrNanDouble(NULL, true)));
2015 CHECK_LLONG_SAME(llrint,(RTStrNanDouble("s", false)));
2016#endif
2017
2018 CHECK_LLONG(RT_NOCRT(llrintf)( +0.0f), 0);
2019 CHECK_LLONG(RT_NOCRT(llrintf)( -0.0f), 0);
2020 CHECK_LLONG(RT_NOCRT(llrintf)( -42.0f), -42);
2021 CHECK_LLONG(RT_NOCRT(llrintf)( -42.5f), -42);
2022 CHECK_LLONG(RT_NOCRT(llrintf)( +42.5f), +42);
2023 CHECK_LLONG(RT_NOCRT(llrintf)( -43.5f), -44);
2024 CHECK_LLONG(RT_NOCRT(llrintf)( +43.5f), +44);
2025 CHECK_LLONG(RT_NOCRT(llrintf)( -42.25f), -42);
2026 CHECK_LLONG(RT_NOCRT(llrintf)( +42.25f), +42);
2027 CHECK_LLONG(RT_NOCRT(llrintf)( -42.75f), -43);
2028 CHECK_LLONG(RT_NOCRT(llrintf)( +42.75f), +43);
2029 CHECK_LLONG(RT_NOCRT(llrintf)(+1234.60958634e+20f), LLONG_MIN);
2030 CHECK_LLONG(RT_NOCRT(llrintf)(-1234.60958634e+20f), LLONG_MIN);
2031 CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e+20f), LLONG_MIN);
2032 CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e-10f), 0);
2033 CHECK_LLONG(RT_NOCRT(llrintf)( -2.1984e-40f), 0); /* subnormal */
2034 CHECK_LLONG(RT_NOCRT(llrintf)(-INFINITY), LLONG_MIN);
2035 CHECK_LLONG(RT_NOCRT(llrintf)(+INFINITY), LLONG_MIN);
2036 CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble(NULL, true)), LLONG_MIN);
2037 CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble("s", false)), LLONG_MIN);
2038 CHECK_LLONG_SAME(llrintf,( -0.0f));
2039 CHECK_LLONG_SAME(llrintf,( +0.0f));
2040 CHECK_LLONG_SAME(llrintf,( +42.25f));
2041 CHECK_LLONG_SAME(llrintf,( -42.25f));
2042 CHECK_LLONG_SAME(llrintf,( +42.75f));
2043 CHECK_LLONG_SAME(llrintf,( -42.75f));
2044 CHECK_LLONG_SAME(llrintf,( +22.5f));
2045 CHECK_LLONG_SAME(llrintf,( -22.5f));
2046 CHECK_LLONG_SAME(llrintf,( +23.5f));
2047 CHECK_LLONG_SAME(llrintf,( -23.5f));
2048 CHECK_LLONG_SAME(llrintf,( +42.25e+6f));
2049 CHECK_LLONG_SAME(llrintf,( -42.25e+6f));
2050 CHECK_LLONG_SAME(llrintf,( -1234.499999e-10f));
2051 CHECK_LLONG_SAME(llrintf,( -2.1984e-40f)); /* subnormal */
2052#if 0 /* Undefined, we disagree with UCRT on windows. */
2053 CHECK_LLONG_SAME(llrintf,(+1234.60958634e+20f));
2054 CHECK_LLONG_SAME(llrintf,(-1234.60958634e+20f));
2055 CHECK_LLONG_SAME(llrintf,( -1234.499999e+20f));
2056 CHECK_LLONG_SAME(llrintf,(-INFINITY));
2057 CHECK_LLONG_SAME(llrintf,(+INFINITY));
2058 CHECK_LLONG_SAME(llrintf,(RTStrNanFloat(NULL, true)));
2059 CHECK_LLONG_SAME(llrintf,(RTStrNanFloat("s", false)));
2060#endif
2061
2062 /*
2063 * Round UP.
2064 */
2065 RT_NOCRT(fesetround)(FE_UPWARD);
2066
2067 CHECK_LLONG(RT_NOCRT(llrint)( +0.0), 0);
2068 CHECK_LLONG(RT_NOCRT(llrint)( -0.0), 0);
2069 CHECK_LLONG(RT_NOCRT(llrint)( -42.0), -42);
2070 CHECK_LLONG(RT_NOCRT(llrint)( -42.5), -42);
2071 CHECK_LLONG(RT_NOCRT(llrint)( +42.5), +43);
2072 CHECK_LLONG(RT_NOCRT(llrint)( -43.5), -43);
2073 CHECK_LLONG(RT_NOCRT(llrint)( +43.5), +44);
2074 CHECK_LLONG(RT_NOCRT(llrint)( -42.25), -42);
2075 CHECK_LLONG(RT_NOCRT(llrint)( +42.25), +43);
2076 CHECK_LLONG(RT_NOCRT(llrint)( -42.75), -42);
2077 CHECK_LLONG(RT_NOCRT(llrint)( +42.75), +43);
2078 CHECK_LLONG(RT_NOCRT(llrint)(+1234.60958634e+20), LLONG_MIN);
2079 CHECK_LLONG(RT_NOCRT(llrint)(-1234.60958634e+20), LLONG_MIN);
2080 CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e+20), LLONG_MIN);
2081 CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e-10), 0);
2082 CHECK_LLONG(RT_NOCRT(llrint)( -2.1984e-310), 0); /* subnormal */
2083 CHECK_LLONG(RT_NOCRT(llrint)(-INFINITY), LLONG_MIN);
2084 CHECK_LLONG(RT_NOCRT(llrint)(+INFINITY), LLONG_MIN);
2085 CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble(NULL, true)),LLONG_MIN);
2086 CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble("s", false)),LLONG_MIN);
2087 CHECK_LLONG_SAME(llrint,( -0.0));
2088 CHECK_LLONG_SAME(llrint,( +0.0));
2089 CHECK_LLONG_SAME(llrint,( +42.25));
2090 CHECK_LLONG_SAME(llrint,( -42.25));
2091 CHECK_LLONG_SAME(llrint,( +42.75));
2092 CHECK_LLONG_SAME(llrint,( -42.75));
2093 CHECK_LLONG_SAME(llrint,( +22.5));
2094 CHECK_LLONG_SAME(llrint,( -22.5));
2095 CHECK_LLONG_SAME(llrint,( +23.5));
2096 CHECK_LLONG_SAME(llrint,( -23.5));
2097 CHECK_LLONG_SAME(llrint,( +42.25e+6));
2098 CHECK_LLONG_SAME(llrint,( -42.25e+6));
2099 CHECK_LLONG_SAME(llrint,( -1234.499999e-10));
2100 CHECK_LLONG_SAME(llrint,( -2.1984e-310)); /* subnormal */
2101#if 0 /* Undefined, we disagree with UCRT on windows. */
2102 CHECK_LLONG_SAME(llrint,(+1234.60958634e+20));
2103 CHECK_LLONG_SAME(llrint,(-1234.60958634e+20));
2104 CHECK_LLONG_SAME(llrint,( -1234.499999e+20));
2105 CHECK_LLONG_SAME(llrint,(-INFINITY));
2106 CHECK_LLONG_SAME(llrint,(+INFINITY));
2107 CHECK_LLONG_SAME(llrint,(RTStrNanDouble(NULL, true)));
2108 CHECK_LLONG_SAME(llrint,(RTStrNanDouble("s", false)));
2109#endif
2110
2111 CHECK_LLONG(RT_NOCRT(llrintf)( +0.0f), 0);
2112 CHECK_LLONG(RT_NOCRT(llrintf)( -0.0f), 0);
2113 CHECK_LLONG(RT_NOCRT(llrintf)( -42.0f), -42);
2114 CHECK_LLONG(RT_NOCRT(llrintf)( -42.5f), -42);
2115 CHECK_LLONG(RT_NOCRT(llrintf)( +42.5f), +43);
2116 CHECK_LLONG(RT_NOCRT(llrintf)( -43.5f), -43);
2117 CHECK_LLONG(RT_NOCRT(llrintf)( +43.5f), +44);
2118 CHECK_LLONG(RT_NOCRT(llrintf)( -42.25f), -42);
2119 CHECK_LLONG(RT_NOCRT(llrintf)( +42.25f), +43);
2120 CHECK_LLONG(RT_NOCRT(llrintf)( -42.75f), -42);
2121 CHECK_LLONG(RT_NOCRT(llrintf)( +42.75f), +43);
2122 CHECK_LLONG(RT_NOCRT(llrintf)(+1234.60958634e+20f), LLONG_MIN);
2123 CHECK_LLONG(RT_NOCRT(llrintf)(-1234.60958634e+20f), LLONG_MIN);
2124 CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e+20f), LLONG_MIN);
2125 CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e-10f), 0);
2126 CHECK_LLONG(RT_NOCRT(llrintf)( -2.1984e-40f), 0); /* subnormal */
2127 CHECK_LLONG(RT_NOCRT(llrintf)(-INFINITY), LLONG_MIN);
2128 CHECK_LLONG(RT_NOCRT(llrintf)(+INFINITY), LLONG_MIN);
2129 CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble(NULL, true)), LLONG_MIN);
2130 CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble("s", false)), LLONG_MIN);
2131 CHECK_LLONG_SAME(llrintf,( -0.0f));
2132 CHECK_LLONG_SAME(llrintf,( +0.0f));
2133 CHECK_LLONG_SAME(llrintf,( +42.25f));
2134 CHECK_LLONG_SAME(llrintf,( -42.25f));
2135 CHECK_LLONG_SAME(llrintf,( +42.75f));
2136 CHECK_LLONG_SAME(llrintf,( -42.75f));
2137 CHECK_LLONG_SAME(llrintf,( +22.5f));
2138 CHECK_LLONG_SAME(llrintf,( -22.5f));
2139 CHECK_LLONG_SAME(llrintf,( +23.5f));
2140 CHECK_LLONG_SAME(llrintf,( -23.5f));
2141 CHECK_LLONG_SAME(llrintf,( +42.25e+6f));
2142 CHECK_LLONG_SAME(llrintf,( -42.25e+6f));
2143 CHECK_LLONG_SAME(llrintf,( -1234.499999e-10f));
2144 CHECK_LLONG_SAME(llrintf,( -2.1984e-40f)); /* subnormal */
2145#if 0 /* Undefined, we disagree with UCRT on windows. */
2146 CHECK_LLONG_SAME(llrintf,(+1234.60958634e+20f));
2147 CHECK_LLONG_SAME(llrintf,(-1234.60958634e+20f));
2148 CHECK_LLONG_SAME(llrintf,( -1234.499999e+20f));
2149 CHECK_LLONG_SAME(llrintf,(-INFINITY));
2150 CHECK_LLONG_SAME(llrintf,(+INFINITY));
2151 CHECK_LLONG_SAME(llrintf,(RTStrNanFloat(NULL, true)));
2152 CHECK_LLONG_SAME(llrintf,(RTStrNanFloat("s", false)));
2153#endif
2154
2155 /*
2156 * Round DOWN.
2157 */
2158 RT_NOCRT(fesetround)(FE_DOWNWARD);
2159
2160 CHECK_LLONG(RT_NOCRT(llrint)( +0.0), 0);
2161 CHECK_LLONG(RT_NOCRT(llrint)( -0.0), 0);
2162 CHECK_LLONG(RT_NOCRT(llrint)( -42.0), -42);
2163 CHECK_LLONG(RT_NOCRT(llrint)( -42.5), -43);
2164 CHECK_LLONG(RT_NOCRT(llrint)( +42.5), +42);
2165 CHECK_LLONG(RT_NOCRT(llrint)( -43.5), -44);
2166 CHECK_LLONG(RT_NOCRT(llrint)( +43.5), +43);
2167 CHECK_LLONG(RT_NOCRT(llrint)( -42.25), -43);
2168 CHECK_LLONG(RT_NOCRT(llrint)( +42.25), +42);
2169 CHECK_LLONG(RT_NOCRT(llrint)( -42.75), -43);
2170 CHECK_LLONG(RT_NOCRT(llrint)( +42.75), +42);
2171 CHECK_LLONG(RT_NOCRT(llrint)(+1234.60958634e+20), LLONG_MIN);
2172 CHECK_LLONG(RT_NOCRT(llrint)(-1234.60958634e+20), LLONG_MIN);
2173 CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e+20), LLONG_MIN);
2174 CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e-10), -1);
2175 CHECK_LLONG(RT_NOCRT(llrint)( -2.1984e-310), -1); /* subnormal */
2176 CHECK_LLONG(RT_NOCRT(llrint)(-INFINITY), LLONG_MIN);
2177 CHECK_LLONG(RT_NOCRT(llrint)(+INFINITY), LLONG_MIN);
2178 CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble(NULL, true)),LLONG_MIN);
2179 CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble("s", false)),LLONG_MIN);
2180 CHECK_LLONG_SAME(llrint,( -0.0));
2181 CHECK_LLONG_SAME(llrint,( +0.0));
2182 CHECK_LLONG_SAME(llrint,( +42.25));
2183 CHECK_LLONG_SAME(llrint,( -42.25));
2184 CHECK_LLONG_SAME(llrint,( +42.75));
2185 CHECK_LLONG_SAME(llrint,( -42.75));
2186 CHECK_LLONG_SAME(llrint,( +22.5));
2187 CHECK_LLONG_SAME(llrint,( -22.5));
2188 CHECK_LLONG_SAME(llrint,( +23.5));
2189 CHECK_LLONG_SAME(llrint,( -23.5));
2190 CHECK_LLONG_SAME(llrint,( +42.25e+6));
2191 CHECK_LLONG_SAME(llrint,( -42.25e+6));
2192 CHECK_LLONG_SAME(llrint,( -1234.499999e-10));
2193 CHECK_LLONG_SAME(llrint,( -2.1984e-310)); /* subnormal */
2194#if 0 /* Undefined, we disagree with UCRT on windows. */
2195 CHECK_LLONG_SAME(llrint,(+1234.60958634e+20));
2196 CHECK_LLONG_SAME(llrint,(-1234.60958634e+20));
2197 CHECK_LLONG_SAME(llrint,( -1234.499999e+20));
2198 CHECK_LLONG_SAME(llrint,(-INFINITY));
2199 CHECK_LLONG_SAME(llrint,(+INFINITY));
2200 CHECK_LLONG_SAME(llrint,(RTStrNanDouble(NULL, true)));
2201 CHECK_LLONG_SAME(llrint,(RTStrNanDouble("s", false)));
2202#endif
2203
2204 CHECK_LLONG(RT_NOCRT(llrintf)( +0.0f), 0);
2205 CHECK_LLONG(RT_NOCRT(llrintf)( -0.0f), 0);
2206 CHECK_LLONG(RT_NOCRT(llrintf)( -42.0f), -42);
2207 CHECK_LLONG(RT_NOCRT(llrintf)( -42.5f), -43);
2208 CHECK_LLONG(RT_NOCRT(llrintf)( +42.5f), +42);
2209 CHECK_LLONG(RT_NOCRT(llrintf)( -43.5f), -44);
2210 CHECK_LLONG(RT_NOCRT(llrintf)( +43.5f), +43);
2211 CHECK_LLONG(RT_NOCRT(llrintf)( -42.25f), -43);
2212 CHECK_LLONG(RT_NOCRT(llrintf)( +42.25f), +42);
2213 CHECK_LLONG(RT_NOCRT(llrintf)( -42.75f), -43);
2214 CHECK_LLONG(RT_NOCRT(llrintf)( +42.75f), +42);
2215 CHECK_LLONG(RT_NOCRT(llrintf)(+1234.60958634e+20f), LLONG_MIN);
2216 CHECK_LLONG(RT_NOCRT(llrintf)(-1234.60958634e+20f), LLONG_MIN);
2217 CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e+20f), LLONG_MIN);
2218 CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e-10f), -1);
2219 CHECK_LLONG(RT_NOCRT(llrintf)( -2.1984e-40f), -1); /* subnormal */
2220 CHECK_LLONG(RT_NOCRT(llrintf)(-INFINITY), LLONG_MIN);
2221 CHECK_LLONG(RT_NOCRT(llrintf)(+INFINITY), LLONG_MIN);
2222 CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble(NULL, true)), LLONG_MIN);
2223 CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble("s", false)), LLONG_MIN);
2224 CHECK_LLONG_SAME(llrintf,( -0.0f));
2225 CHECK_LLONG_SAME(llrintf,( +0.0f));
2226 CHECK_LLONG_SAME(llrintf,( +42.25f));
2227 CHECK_LLONG_SAME(llrintf,( -42.25f));
2228 CHECK_LLONG_SAME(llrintf,( +42.75f));
2229 CHECK_LLONG_SAME(llrintf,( -42.75f));
2230 CHECK_LLONG_SAME(llrintf,( +22.5f));
2231 CHECK_LLONG_SAME(llrintf,( -22.5f));
2232 CHECK_LLONG_SAME(llrintf,( +23.5f));
2233 CHECK_LLONG_SAME(llrintf,( -23.5f));
2234 CHECK_LLONG_SAME(llrintf,( +42.25e+6f));
2235 CHECK_LLONG_SAME(llrintf,( -42.25e+6f));
2236 CHECK_LLONG_SAME(llrintf,( -1234.499999e-10f));
2237 CHECK_LLONG_SAME(llrintf,( -2.1984e-40f)); /* subnormal */
2238#if 0 /* Undefined, we disagree with UCRT on windows. */
2239 CHECK_LLONG_SAME(llrintf,(+1234.60958634e+20f));
2240 CHECK_LLONG_SAME(llrintf,(-1234.60958634e+20f));
2241 CHECK_LLONG_SAME(llrintf,( -1234.499999e+20f));
2242 CHECK_LLONG_SAME(llrintf,(-INFINITY));
2243 CHECK_LLONG_SAME(llrintf,(+INFINITY));
2244 CHECK_LLONG_SAME(llrintf,(RTStrNanFloat(NULL, true)));
2245 CHECK_LLONG_SAME(llrintf,(RTStrNanFloat("s", false)));
2246#endif
2247
2248 /*
2249 * Round towards ZERO.
2250 */
2251 RT_NOCRT(fesetround)(FE_TOWARDZERO);
2252
2253 CHECK_LLONG(RT_NOCRT(llrint)( +0.0), 0);
2254 CHECK_LLONG(RT_NOCRT(llrint)( -0.0), 0);
2255 CHECK_LLONG(RT_NOCRT(llrint)( -42.0), -42);
2256 CHECK_LLONG(RT_NOCRT(llrint)( -42.5), -42);
2257 CHECK_LLONG(RT_NOCRT(llrint)( +42.5), +42);
2258 CHECK_LLONG(RT_NOCRT(llrint)( -43.5), -43);
2259 CHECK_LLONG(RT_NOCRT(llrint)( +43.5), +43);
2260 CHECK_LLONG(RT_NOCRT(llrint)( -42.25), -42);
2261 CHECK_LLONG(RT_NOCRT(llrint)( +42.25), +42);
2262 CHECK_LLONG(RT_NOCRT(llrint)( -42.75), -42);
2263 CHECK_LLONG(RT_NOCRT(llrint)( +42.75), +42);
2264 CHECK_LLONG(RT_NOCRT(llrint)(+1234.60958634e+20), LLONG_MIN);
2265 CHECK_LLONG(RT_NOCRT(llrint)(-1234.60958634e+20), LLONG_MIN);
2266 CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e+20), LLONG_MIN);
2267 CHECK_LLONG(RT_NOCRT(llrint)( -1234.499999e-10), 0);
2268 CHECK_LLONG(RT_NOCRT(llrint)( -2.1984e-310), 0); /* subnormal */
2269 CHECK_LLONG(RT_NOCRT(llrint)(-INFINITY), LLONG_MIN);
2270 CHECK_LLONG(RT_NOCRT(llrint)(+INFINITY), LLONG_MIN);
2271 CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble(NULL, true)),LLONG_MIN);
2272 CHECK_LLONG(RT_NOCRT(llrint)(RTStrNanDouble("s", false)),LLONG_MIN);
2273 CHECK_LLONG_SAME(llrint,( -0.0));
2274 CHECK_LLONG_SAME(llrint,( +0.0));
2275 CHECK_LLONG_SAME(llrint,( +42.25));
2276 CHECK_LLONG_SAME(llrint,( -42.25));
2277 CHECK_LLONG_SAME(llrint,( +42.75));
2278 CHECK_LLONG_SAME(llrint,( -42.75));
2279 CHECK_LLONG_SAME(llrint,( +22.5));
2280 CHECK_LLONG_SAME(llrint,( -22.5));
2281 CHECK_LLONG_SAME(llrint,( +23.5));
2282 CHECK_LLONG_SAME(llrint,( -23.5));
2283 CHECK_LLONG_SAME(llrint,( +42.25e+6));
2284 CHECK_LLONG_SAME(llrint,( -42.25e+6));
2285 CHECK_LLONG_SAME(llrint,( -1234.499999e-10));
2286 CHECK_LLONG_SAME(llrint,( -2.1984e-310)); /* subnormal */
2287#if 0 /* Undefined, we disagree with UCRT on windows. */
2288 CHECK_LLONG_SAME(llrint,(+1234.60958634e+20));
2289 CHECK_LLONG_SAME(llrint,(-1234.60958634e+20));
2290 CHECK_LLONG_SAME(llrint,( -1234.499999e+20));
2291 CHECK_LLONG_SAME(llrint,(-INFINITY));
2292 CHECK_LLONG_SAME(llrint,(+INFINITY));
2293 CHECK_LLONG_SAME(llrint,(RTStrNanDouble(NULL, true)));
2294 CHECK_LLONG_SAME(llrint,(RTStrNanDouble("s", false)));
2295#endif
2296
2297 CHECK_LLONG(RT_NOCRT(llrintf)( +0.0f), 0);
2298 CHECK_LLONG(RT_NOCRT(llrintf)( -0.0f), 0);
2299 CHECK_LLONG(RT_NOCRT(llrintf)( -42.0f), -42);
2300 CHECK_LLONG(RT_NOCRT(llrintf)( -42.5f), -42);
2301 CHECK_LLONG(RT_NOCRT(llrintf)( +42.5f), +42);
2302 CHECK_LLONG(RT_NOCRT(llrintf)( -43.5f), -43);
2303 CHECK_LLONG(RT_NOCRT(llrintf)( +43.5f), +43);
2304 CHECK_LLONG(RT_NOCRT(llrintf)( -42.25f), -42);
2305 CHECK_LLONG(RT_NOCRT(llrintf)( +42.25f), +42);
2306 CHECK_LLONG(RT_NOCRT(llrintf)( -42.75f), -42);
2307 CHECK_LLONG(RT_NOCRT(llrintf)( +42.75f), +42);
2308 CHECK_LLONG(RT_NOCRT(llrintf)(+1234.60958634e+20f), LLONG_MIN);
2309 CHECK_LLONG(RT_NOCRT(llrintf)(-1234.60958634e+20f), LLONG_MIN);
2310 CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e+20f), LLONG_MIN);
2311 CHECK_LLONG(RT_NOCRT(llrintf)( -1234.499999e-10f), 0);
2312 CHECK_LLONG(RT_NOCRT(llrintf)( -2.1984e-40f), 0); /* subnormal */
2313 CHECK_LLONG(RT_NOCRT(llrintf)(-INFINITY), LLONG_MIN);
2314 CHECK_LLONG(RT_NOCRT(llrintf)(+INFINITY), LLONG_MIN);
2315 CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble(NULL, true)), LLONG_MIN);
2316 CHECK_LLONG(RT_NOCRT(llrintf)(RTStrNanDouble("s", false)), LLONG_MIN);
2317 CHECK_LLONG_SAME(llrintf,( -0.0f));
2318 CHECK_LLONG_SAME(llrintf,( +0.0f));
2319 CHECK_LLONG_SAME(llrintf,( +42.25f));
2320 CHECK_LLONG_SAME(llrintf,( -42.25f));
2321 CHECK_LLONG_SAME(llrintf,( +42.75f));
2322 CHECK_LLONG_SAME(llrintf,( -42.75f));
2323 CHECK_LLONG_SAME(llrintf,( +22.5f));
2324 CHECK_LLONG_SAME(llrintf,( -22.5f));
2325 CHECK_LLONG_SAME(llrintf,( +23.5f));
2326 CHECK_LLONG_SAME(llrintf,( -23.5f));
2327 CHECK_LLONG_SAME(llrintf,( +42.25e+6f));
2328 CHECK_LLONG_SAME(llrintf,( -42.25e+6f));
2329 CHECK_LLONG_SAME(llrintf,( -1234.499999e-10f));
2330 CHECK_LLONG_SAME(llrintf,( -2.1984e-40f)); /* subnormal */
2331#if 0 /* Undefined, we disagree with UCRT on windows. */
2332 CHECK_LLONG_SAME(llrintf,(+1234.60958634e+20f));
2333 CHECK_LLONG_SAME(llrintf,(-1234.60958634e+20f));
2334 CHECK_LLONG_SAME(llrintf,( -1234.499999e+20f));
2335 CHECK_LLONG_SAME(llrintf,(-INFINITY));
2336 CHECK_LLONG_SAME(llrintf,(+INFINITY));
2337 CHECK_LLONG_SAME(llrintf,(RTStrNanFloat(NULL, true)));
2338 CHECK_LLONG_SAME(llrintf,(RTStrNanFloat("s", false)));
2339#endif
2340
2341 RT_NOCRT(fesetround)(iSavedMode);
2342}
2343
2344
2345void testExp2()
2346{
2347 RTTestSub(g_hTest, "exp2[f]");
2348
2349 CHECK_DBL(RT_NOCRT(exp2)(1.0), 2.0);
2350 CHECK_DBL(RT_NOCRT(exp2)(2.0), 4.0);
2351 CHECK_DBL(RT_NOCRT(exp2)(32.0), 4294967296.0);
2352 CHECK_DBL(RT_NOCRT(exp2)(-1.0), 0.5);
2353 CHECK_DBL(RT_NOCRT(exp2)(-3.0), 0.125);
2354 CHECK_DBL_SAME(exp2, (0.0));
2355 CHECK_DBL_SAME(exp2, (+INFINITY));
2356 CHECK_DBL_SAME(exp2, (-INFINITY));
2357 CHECK_DBL_SAME(exp2, (nan("1")));
2358 CHECK_DBL_SAME(exp2, (RTStrNanDouble("ab305f", true)));
2359 CHECK_DBL_SAME(exp2, (RTStrNanDouble("fffffffff_signaling", true)));
2360 CHECK_DBL_SAME(exp2, (RTStrNanDouble("7777777777778_sig", false)));
2361 CHECK_DBL_SAME(exp2, (1.0));
2362 CHECK_DBL_SAME(exp2, (2.0));
2363 CHECK_DBL_SAME(exp2, (-1.0));
2364 CHECK_DBL_APPROX_SAME(exp2, (+0.5));
2365 CHECK_DBL_APPROX_SAME(exp2, (-0.5));
2366 CHECK_DBL_APPROX_SAME(exp2, (+1.5));
2367 CHECK_DBL_APPROX_SAME(exp2, (-1.5));
2368 CHECK_DBL_APPROX_SAME(exp2, (+3.25));
2369 CHECK_DBL_APPROX_SAME(exp2, (99.2559430));
2370 CHECK_DBL_APPROX_SAME(exp2, (-99.2559430));
2371 CHECK_DBL_APPROX_SAME(exp2, (+305.2559430));
2372 CHECK_DBL_APPROX_SAME(exp2, (-305.2559430));
2373 CHECK_DBL_APPROX_SAME(exp2, (+309.99884));
2374 CHECK_DBL_APPROX_SAME(exp2, (-309.111048));
2375 CHECK_DBL_APPROX_SAME(exp2, (+999.864597634));
2376 CHECK_DBL_APPROX_SAME(exp2, (-999.098234837));
2377
2378
2379 CHECK_FLT(RT_NOCRT(exp2f)(1.0f), 2.0f);
2380 CHECK_FLT(RT_NOCRT(exp2f)(2.0f), 4.0f);
2381 CHECK_FLT(RT_NOCRT(exp2f)(32.0f), 4294967296.0f);
2382 CHECK_FLT(RT_NOCRT(exp2f)(-1.0f), 0.5f);
2383 CHECK_FLT(RT_NOCRT(exp2f)(-3.0f), 0.125f);
2384 CHECK_FLT_SAME(exp2f, (0.0f));
2385 CHECK_FLT_SAME(exp2f, (+INFINITY));
2386 CHECK_FLT_SAME(exp2f, (-INFINITY));
2387 CHECK_FLT_SAME(exp2f, (nan("1")));
2388 CHECK_FLT_SAME(exp2f, (RTStrNanFloat("ab305f", true)));
2389 CHECK_FLT_SAME(exp2f, (RTStrNanFloat("3fffff_signaling", true)));
2390 CHECK_FLT_SAME(exp2f, (RTStrNanFloat("79778_sig", false)));
2391 CHECK_FLT_SAME(exp2f, (1.0f));
2392 CHECK_FLT_SAME(exp2f, (2.0f));
2393 CHECK_FLT_SAME(exp2f, (-1.0f));
2394 CHECK_FLT_APPROX_SAME(exp2f, (+0.5f));
2395 CHECK_FLT_APPROX_SAME(exp2f, (-0.5f));
2396 CHECK_FLT_APPROX_SAME(exp2f, (+1.5f));
2397 CHECK_FLT_APPROX_SAME(exp2f, (-1.5f));
2398 CHECK_FLT_APPROX_SAME(exp2f, (+3.25f));
2399 CHECK_FLT_APPROX_SAME(exp2f, (99.25594f));
2400 CHECK_FLT_APPROX_SAME(exp2f, (-99.25594f));
2401 CHECK_FLT_APPROX_SAME(exp2f, (+305.25594f));
2402 CHECK_FLT_APPROX_SAME(exp2f, (-305.25594f));
2403 CHECK_FLT_APPROX_SAME(exp2f, (+309.99884f));
2404 CHECK_FLT_APPROX_SAME(exp2f, (-309.111048f));
2405 CHECK_FLT_APPROX_SAME(exp2f, (+999.86459f));
2406 CHECK_FLT_APPROX_SAME(exp2f, (-999.09823f));
2407}
2408
2409
2410void testLdExp()
2411{
2412 RTTestSub(g_hTest, "ldexp[f]");
2413
2414 CHECK_DBL(RT_NOCRT(ldexp)(1.0, 1), 2.0);
2415 CHECK_DBL(RT_NOCRT(ldexp)(1.0, 2), 4.0);
2416 CHECK_DBL(RT_NOCRT(ldexp)(1.0, 32), 4294967296.0);
2417 CHECK_DBL(RT_NOCRT(ldexp)(2.0, 31), 4294967296.0);
2418 CHECK_DBL(RT_NOCRT(ldexp)(0.5, 33), 4294967296.0);
2419 CHECK_DBL(RT_NOCRT(ldexp)(1.0, -1), 0.5);
2420 CHECK_DBL(RT_NOCRT(ldexp)(1.0, -3), 0.125);
2421 CHECK_DBL_SAME(ldexp, (0.0, 0));
2422 CHECK_DBL_SAME(ldexp, (+INFINITY, 1));
2423 CHECK_DBL_SAME(ldexp, (+INFINITY, 2));
2424 CHECK_DBL_SAME(ldexp, (-INFINITY, 1));
2425 CHECK_DBL_SAME(ldexp, (-INFINITY, 2));
2426 CHECK_DBL_SAME(ldexp, (nan("1"), 1));
2427 CHECK_DBL_SAME(ldexp, (RTStrNanDouble("ab305f", true), 2));
2428 CHECK_DBL_SAME(ldexp, (RTStrNanDouble("fffffffff_signaling", true), 3));
2429 CHECK_DBL_SAME(ldexp, (RTStrNanDouble("7777777777778_sig", false), -4));
2430 CHECK_DBL_SAME(ldexp, ( 1.0, 1));
2431 CHECK_DBL_SAME(ldexp, ( 2.0, 2));
2432 CHECK_DBL_SAME(ldexp, ( -1.0, -1));
2433 CHECK_DBL_SAME(ldexp, ( +0.5, 63));
2434 CHECK_DBL_SAME(ldexp, ( -0.5, -73));
2435 CHECK_DBL_SAME(ldexp, ( +1.5, -88));
2436 CHECK_DBL_SAME(ldexp, ( -1.5, 99));
2437 CHECK_DBL_SAME(ldexp, ( +3.25, -102));
2438 CHECK_DBL_SAME(ldexp, ( 99.2559430, -256));
2439 CHECK_DBL_SAME(ldexp, ( -99.2559430, 256));
2440 CHECK_DBL_SAME(ldexp, ( +305.2559430, 34));
2441 CHECK_DBL_SAME(ldexp, ( -305.2559430, 79));
2442 CHECK_DBL_SAME(ldexp, ( +309.99884, -99));
2443 CHECK_DBL_SAME(ldexp, ( -309.111048, -38));
2444 CHECK_DBL_SAME(ldexp, (+999.864597634, -21));
2445 CHECK_DBL_SAME(ldexp, (-999.098234837, 21));
2446
2447 CHECK_FLT(RT_NOCRT(ldexpf)(1.0f, 1), 2.0f);
2448 CHECK_FLT(RT_NOCRT(ldexpf)(1.0f, 2), 4.0f);
2449 CHECK_FLT(RT_NOCRT(ldexpf)(1.0f, 32), 4294967296.0f);
2450 CHECK_FLT(RT_NOCRT(ldexpf)(2.0f, 31), 4294967296.0f);
2451 CHECK_FLT(RT_NOCRT(ldexpf)(0.5f, 33), 4294967296.0f);
2452 CHECK_FLT(RT_NOCRT(ldexpf)(1.0f, -1), 0.5f);
2453 CHECK_FLT(RT_NOCRT(ldexpf)(1.0f, -3), 0.125f);
2454 CHECK_FLT_SAME(ldexpf, (0.0f, 0));
2455 CHECK_FLT_SAME(ldexpf, (+INFINITY, 1));
2456 CHECK_FLT_SAME(ldexpf, (+INFINITY, 2));
2457 CHECK_FLT_SAME(ldexpf, (-INFINITY, 1));
2458 CHECK_FLT_SAME(ldexpf, (-INFINITY, 2));
2459 CHECK_FLT_SAME(ldexpf, (nan("1"), 1));
2460 CHECK_FLT_SAME(ldexpf, (RTStrNanDouble("ab305f", true), 2));
2461 CHECK_FLT_SAME(ldexpf, (RTStrNanDouble("fffffffff_signaling", true), 3));
2462 CHECK_FLT_SAME(ldexpf, (RTStrNanDouble("7777777777778_sig", false), -4));
2463 CHECK_FLT_SAME(ldexpf, ( 1.0f, 1));
2464 CHECK_FLT_SAME(ldexpf, ( 2.0f, 2));
2465 CHECK_FLT_SAME(ldexpf, ( -1.0f, -1));
2466 CHECK_FLT_SAME(ldexpf, ( +0.5f, 63));
2467 CHECK_FLT_SAME(ldexpf, ( -0.5f, -73));
2468 CHECK_FLT_SAME(ldexpf, ( +1.5f, -88));
2469 CHECK_FLT_SAME(ldexpf, ( -1.5f, 99));
2470 CHECK_FLT_SAME(ldexpf, ( +3.25f, -102));
2471 CHECK_FLT_SAME(ldexpf, ( 99.2559430f, -256));
2472 CHECK_FLT_SAME(ldexpf, ( -99.2559430f, 256));
2473 CHECK_FLT_SAME(ldexpf, ( +305.2559430f, 34));
2474 CHECK_FLT_SAME(ldexpf, ( -305.2559430f, 79));
2475 CHECK_FLT_SAME(ldexpf, ( +309.99884f, -99));
2476 CHECK_FLT_SAME(ldexpf, ( -309.111048f, -38));
2477 CHECK_FLT_SAME(ldexpf, (+999.864597634f, -21));
2478 CHECK_FLT_SAME(ldexpf, (-999.098234837f, 21));
2479
2480}
2481
2482
2483void testFma()
2484{
2485 RTTestSub(g_hTest, "fma[f]");
2486
2487 CHECK_DBL(RT_NOCRT(fma)(1.0, 1.0, 1.0), 2.0);
2488 CHECK_DBL(RT_NOCRT(fma)(4.0, 2.0, 1.0), 9.0);
2489 CHECK_DBL(RT_NOCRT(fma)(4.0, 2.0, -1.0), 7.0);
2490 CHECK_DBL_SAME(fma, (0.0, 0.0, 0.0));
2491 CHECK_DBL_SAME(fma, (999999.0, 33334.0, 29345.0));
2492 CHECK_DBL_SAME(fma, (39560.32334, 9605.5546, -59079.345069));
2493 CHECK_DBL_SAME(fma, (39560.32334, -59079.345069, 9605.5546));
2494 CHECK_DBL_SAME(fma, (-59079.345069, 39560.32334, 9605.5546));
2495 CHECK_DBL_SAME(fma, (+INFINITY, +INFINITY, -INFINITY));
2496 CHECK_DBL_SAME(fma, (4.0, +INFINITY, 2.0));
2497 CHECK_DBL_SAME(fma, (4.0, 4.0, +INFINITY));
2498 CHECK_DBL_SAME(fma, (-INFINITY, 4.0, 4.0));
2499 CHECK_DBL_SAME(fma, (2.34960584706e100, 7.6050698459e-13, 9.99996777e77));
2500
2501 CHECK_FLT(RT_NOCRT(fmaf)(1.0f, 1.0f, 1.0), 2.0);
2502 CHECK_FLT(RT_NOCRT(fmaf)(4.0f, 2.0f, 1.0), 9.0);
2503 CHECK_FLT(RT_NOCRT(fmaf)(4.0f, 2.0f, -1.0), 7.0);
2504 CHECK_FLT_SAME(fmaf, (0.0f, 0.0f, 0.0f));
2505 CHECK_FLT_SAME(fmaf, (999999.0f, 33334.0f, 29345.0f));
2506 CHECK_FLT_SAME(fmaf, (39560.32334f, 9605.5546f, -59079.345069f));
2507 CHECK_FLT_SAME(fmaf, (39560.32334f, -59079.345069f, 9605.5546f));
2508 CHECK_FLT_SAME(fmaf, (-59079.345069f, 39560.32334f, 9605.5546f));
2509 CHECK_FLT_SAME(fmaf, (+INFINITY, +INFINITY, -INFINITY));
2510 CHECK_FLT_SAME(fmaf, (4.0f, +INFINITY, 2.0f));
2511 CHECK_FLT_SAME(fmaf, (4.0f, 4.0f, +INFINITY));
2512 CHECK_FLT_SAME(fmaf, (-INFINITY, 4.0f, 4.0f));
2513 CHECK_FLT_SAME(fmaf, (2.34960584706e22f, 7.6050698459e-13f, 9.99996777e27f));
2514}
2515
2516
2517void testRemainder()
2518{
2519 RTTestSub(g_hTest, "remainder[f]");
2520
2521 /* The UCRT and x87 FPU generally disagree on the sign of the NaN, so don't be too picky here for now. */
2522
2523 CHECK_DBL( RT_NOCRT(remainder)( 1.0, 1.0), +0.0);
2524 CHECK_DBL( RT_NOCRT(remainder)( 1.5, 1.0), -0.5);
2525 CHECK_DBL_SAME_RELAXED_NAN(remainder,( 1.0, 1.0));
2526 CHECK_DBL_SAME_RELAXED_NAN(remainder,( 1.5, 1.0));
2527 CHECK_DBL_SAME_RELAXED_NAN(remainder,( +0.0, +0.0));
2528 CHECK_DBL_SAME_RELAXED_NAN(remainder,( +0.0, -0.0));
2529 CHECK_DBL_SAME_RELAXED_NAN(remainder,( -0.0, -0.0));
2530 CHECK_DBL_SAME_RELAXED_NAN(remainder,( -0.0, +0.0));
2531 CHECK_DBL_SAME_RELAXED_NAN(remainder,( 999999.0, 33334.0));
2532 CHECK_DBL_SAME_RELAXED_NAN(remainder,( -999999.0, 33334.0));
2533 CHECK_DBL_SAME_RELAXED_NAN(remainder,( -999999.0, -33334.0));
2534 CHECK_DBL_SAME_RELAXED_NAN(remainder,( 999999.0, -33334.0));
2535 CHECK_DBL_SAME_RELAXED_NAN(remainder,( 39560.32334, 9605.5546));
2536 CHECK_DBL_SAME_RELAXED_NAN(remainder,( 39560.32334, -59079.345069));
2537 CHECK_DBL_SAME_RELAXED_NAN(remainder,( +INFINITY, +INFINITY));
2538 CHECK_DBL_SAME_RELAXED_NAN(remainder,( 2.4, +INFINITY));
2539 CHECK_DBL_SAME_RELAXED_NAN(remainder,( +INFINITY, 2.4));
2540 CHECK_DBL_SAME_RELAXED_NAN(remainder,(2.34960584706e100, 7.6050698459e+13));
2541 CHECK_DBL_SAME_RELAXED_NAN(remainder,(2.34960584706e300, -7.6050698459e-13));
2542 CHECK_DBL_SAME_RELAXED_NAN(remainder,(2.34960584706e300, RTStrNanDouble(NULL, true)));
2543 CHECK_DBL_SAME_RELAXED_NAN(remainder,(RTStrNanDouble(NULL, true), 2.0));
2544 CHECK_DBL_SAME_RELAXED_NAN(remainder,(RTStrNanDouble(NULL, true), RTStrNanDouble("s", false)));
2545
2546 CHECK_FLT( RT_NOCRT(remainderf)( 1.0f, 1.0f), +0.0f);
2547 CHECK_FLT( RT_NOCRT(remainderf)( 1.5f, 1.0f), -0.5f);
2548 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 1.0f, 1.0f));
2549 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 1.5f, 1.0f));
2550 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( +0.0f, +0.0f));
2551 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( +0.0f, -0.0f));
2552 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( -0.0f, -0.0f));
2553 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( -0.0f, +0.0f));
2554 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 999999.0f, 33334.0f));
2555 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( -999999.0f, 33334.0f));
2556 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( -999999.0f, -33334.0f));
2557 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 999999.0f, -33334.0f));
2558 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 39560.32334f, 9605.5546f));
2559 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 39560.32334f, -59079.345069f));
2560 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( +INFINITY, +INFINITY));
2561 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( 2.4f, +INFINITY));
2562 CHECK_FLT_SAME_RELAXED_NAN(remainderf,( +INFINITY, 2.4f));
2563 CHECK_FLT_SAME_RELAXED_NAN(remainderf,(-2.34960584706e+35f, 7.6050698459e-23f));
2564 CHECK_FLT_SAME_RELAXED_NAN(remainderf,(2.34960584706e+35f, 7.6050698459e-13f));
2565 CHECK_FLT_SAME_RELAXED_NAN(remainderf,(2.34960584706e+30f, RTStrNanFloat(NULL, true)));
2566 CHECK_FLT_SAME_RELAXED_NAN(remainderf,(RTStrNanFloat(NULL, true), 2.0f));
2567 CHECK_FLT_SAME_RELAXED_NAN(remainderf,(RTStrNanFloat(NULL, true), RTStrNanFloat("s", false)));
2568}
2569
2570
2571void testLog()
2572{
2573 RTTestSub(g_hTest, "log[f]");
2574
2575 CHECK_DBL(RT_NOCRT(log)( 1.0), +0.0);
2576 CHECK_DBL(RT_NOCRT(log)(2.7182818284590452354), +1.0);
2577 CHECK_DBL(RT_NOCRT(log)(2.0), 0.69314718055994530942);
2578 CHECK_DBL_SAME(log,( 1.0));
2579 CHECK_DBL_SAME(log,( 1.5));
2580 CHECK_DBL_SAME(log,( +0.0));
2581 CHECK_DBL_SAME(log,( +0.0));
2582 CHECK_DBL_SAME(log,( -0.0));
2583 CHECK_DBL_SAME(log,( -0.0));
2584 CHECK_DBL_SAME(log,( 999999.0));
2585 CHECK_DBL_SAME(log,( -999999.0));
2586 CHECK_DBL_SAME(log,( -999999.0));
2587 CHECK_DBL_SAME(log,( 999999.0));
2588 CHECK_DBL_SAME(log,( 39560.32334));
2589 CHECK_DBL_SAME(log,( 39560.32334));
2590 CHECK_DBL_SAME(log,( +INFINITY));
2591 CHECK_DBL_SAME(log,( -INFINITY));
2592 CHECK_DBL_SAME(log,( +DBL_MAX));
2593 CHECK_DBL_SAME(log,( -DBL_MAX));
2594 CHECK_DBL_SAME(log,(2.34960584706e100));
2595 CHECK_DBL_SAME(log,(2.34960584706e300));
2596 CHECK_DBL_SAME(log,(2.34960584706e300));
2597 CHECK_DBL_SAME(log,(RTStrNanDouble(NULL, true)));
2598 CHECK_DBL_SAME(log,(RTStrNanDouble("s", true)));
2599 CHECK_DBL_SAME(log,(RTStrNanDouble("s", false)));
2600
2601 CHECK_FLT(RT_NOCRT(logf)( 1.0f), +0.0f);
2602 CHECK_FLT(RT_NOCRT(logf)((float)2.7182818284590452354), +0.99999995f); /* floating point is fun */
2603 CHECK_FLT(RT_NOCRT(logf)(2.0f), (float)0.69314718055994530942);
2604 CHECK_FLT_SAME(logf,((float)2.7182818284590452354));
2605 CHECK_FLT_SAME(logf,( 1.0f));
2606 CHECK_FLT_SAME(logf,( 1.5f));
2607 CHECK_FLT_SAME(logf,( +0.0f));
2608 CHECK_FLT_SAME(logf,( +0.0f));
2609 CHECK_FLT_SAME(logf,( -0.0f));
2610 CHECK_FLT_SAME(logf,( -0.0f));
2611 CHECK_FLT_SAME(logf,( 999999.0f));
2612 CHECK_FLT_SAME(logf,( -999999.0f));
2613 CHECK_FLT_SAME(logf,( -999999.0f));
2614 CHECK_FLT_SAME(logf,( 999999.0f));
2615 CHECK_FLT_SAME(logf,( 39560.32334f));
2616 CHECK_FLT_SAME(logf,( 39560.32334f));
2617 CHECK_FLT_SAME(logf,( +INFINITY));
2618 CHECK_FLT_SAME(logf,( -INFINITY));
2619 CHECK_FLT_SAME(logf,( +FLT_MAX));
2620 CHECK_FLT_SAME(logf,( -FLT_MAX));
2621 CHECK_FLT_SAME(logf,(2.34960584706e+10f));
2622 CHECK_FLT_SAME(logf,(2.34960584706e+30f));
2623 CHECK_FLT_SAME(logf,(2.34960584706e+30f));
2624 CHECK_FLT_SAME(logf,(RTStrNanFloat(NULL, true)));
2625 CHECK_FLT_SAME(logf,(RTStrNanFloat("s", true)));
2626 CHECK_FLT_SAME(logf,(RTStrNanFloat("s", false)));
2627}
2628
2629
2630void testSqRt()
2631{
2632 RTTestSub(g_hTest, "sqrt[f]");
2633
2634 CHECK_DBL(RT_NOCRT(sqrt)( 1.0), +1.0);
2635 CHECK_DBL(RT_NOCRT(sqrt)( 4.0), +2.0);
2636 CHECK_DBL(RT_NOCRT(sqrt)( 144.0), +12.0);
2637 CHECK_DBL(RT_NOCRT(sqrt)( -1.0), RTStrNanDouble(NULL, false));
2638 CHECK_DBL(RT_NOCRT(sqrt)( -995.4547), RTStrNanDouble(NULL, false));
2639 CHECK_DBL_SAME( sqrt,( 1.0));
2640 CHECK_DBL_SAME( sqrt,( 1.5));
2641 CHECK_DBL_SAME( sqrt,( +0.0));
2642 CHECK_DBL_SAME( sqrt,( +0.0));
2643 CHECK_DBL_SAME( sqrt,( -0.0));
2644 CHECK_DBL_SAME( sqrt,( -0.0));
2645 CHECK_DBL_SAME( sqrt,( 999999.0));
2646 CHECK_DBL_SAME( sqrt,( -999999.0));
2647 CHECK_DBL_SAME( sqrt,( -999999.0));
2648 CHECK_DBL_SAME( sqrt,( 999999.0));
2649 CHECK_DBL_SAME( sqrt,( 39560.32334));
2650 CHECK_DBL_SAME( sqrt,( 39560.32334));
2651 CHECK_DBL_SAME( sqrt,( +INFINITY));
2652 CHECK_DBL_SAME( sqrt,( -INFINITY));
2653 CHECK_DBL_SAME( sqrt,( +DBL_MAX));
2654 CHECK_DBL_SAME( sqrt,( -DBL_MAX));
2655 CHECK_DBL_SAME( sqrt,(2.34960584706e100));
2656 CHECK_DBL_SAME( sqrt,(2.34960584706e300));
2657 CHECK_DBL_SAME( sqrt,(2.34960584706e300));
2658 CHECK_DBL_SAME( sqrt,(RTStrNanDouble(NULL, true)));
2659 CHECK_DBL_SAME( sqrt,(RTStrNanDouble("s", true)));
2660 CHECK_DBL_SAME( sqrt,(RTStrNanDouble("s", false)));
2661
2662 CHECK_FLT(RT_NOCRT(sqrtf)( 1.0f), +1.0f);
2663 CHECK_FLT(RT_NOCRT(sqrtf)( 4.0f), +2.0f);
2664 CHECK_FLT(RT_NOCRT(sqrtf)( 144.0f), +12.0f);
2665 CHECK_FLT(RT_NOCRT(sqrtf)( -1.0f), RTStrNanDouble(NULL, false));
2666 CHECK_FLT(RT_NOCRT(sqrtf)( -995.4547f), RTStrNanDouble(NULL, false));
2667 CHECK_FLT_SAME( sqrtf,( 1.0f));
2668 CHECK_FLT_SAME( sqrtf,( 1.5f));
2669 CHECK_FLT_SAME( sqrtf,( +0.0f));
2670 CHECK_FLT_SAME( sqrtf,( +0.0f));
2671 CHECK_FLT_SAME( sqrtf,( -0.0f));
2672 CHECK_FLT_SAME( sqrtf,( -0.0f));
2673 CHECK_FLT_SAME( sqrtf,( 999999.0f));
2674 CHECK_FLT_SAME( sqrtf,( -999999.0f));
2675 CHECK_FLT_SAME( sqrtf,( -999999.0f));
2676 CHECK_FLT_SAME( sqrtf,( 999999.0f));
2677 CHECK_FLT_SAME( sqrtf,( 39560.32334f));
2678 CHECK_FLT_SAME( sqrtf,( 39560.32334f));
2679 CHECK_FLT_SAME( sqrtf,( +INFINITY));
2680 CHECK_FLT_SAME( sqrtf,( -INFINITY));
2681 CHECK_FLT_SAME( sqrtf,( +FLT_MAX));
2682 CHECK_FLT_SAME( sqrtf,( -FLT_MAX));
2683 CHECK_FLT_SAME( sqrtf,(2.34960584706e+10f));
2684 CHECK_FLT_SAME( sqrtf,(2.34960584706e+30f));
2685 CHECK_FLT_SAME( sqrtf,(2.34960584706e+30f));
2686 CHECK_FLT_SAME( sqrtf,(RTStrNanDouble(NULL, true)));
2687 CHECK_FLT_SAME( sqrtf,(RTStrNanDouble("s", true)));
2688 CHECK_FLT_SAME( sqrtf,(RTStrNanDouble("s", false)));
2689}
2690
2691
2692void testATan()
2693{
2694 RTTestSub(g_hTest, "atan[f]");
2695
2696 CHECK_DBL(RT_NOCRT(atan)( +1.0), +0.78539816339744830962 /*+M_PI_4*/);
2697 CHECK_DBL(RT_NOCRT(atan)( -1.0), -0.78539816339744830962 /*-M_PI_4*/);
2698 CHECK_DBL(RT_NOCRT(atan)( +INFINITY), +1.57079632679489661923 /*+M_PI_2*/);
2699 CHECK_DBL(RT_NOCRT(atan)( -INFINITY), -1.57079632679489661923 /*-M_PI_2*/);
2700 CHECK_DBL_SAME( atan,( 1.0));
2701 CHECK_DBL_SAME( atan,( 1.5));
2702 CHECK_DBL_SAME( atan,( +0.0));
2703 CHECK_DBL_SAME( atan,( +0.0));
2704 CHECK_DBL_SAME( atan,( -0.0));
2705 CHECK_DBL_SAME( atan,( -0.0));
2706 CHECK_DBL_SAME( atan,( 238.6634566));
2707 CHECK_DBL_SAME( atan,( -49.4578999));
2708 CHECK_DBL_SAME( atan,( 999999.0));
2709 CHECK_DBL_SAME( atan,( -999999.0));
2710 CHECK_DBL_SAME( atan,( -999999.0));
2711 CHECK_DBL_SAME( atan,( 999999.0));
2712 CHECK_DBL_SAME( atan,( 39560.32334));
2713 CHECK_DBL_SAME( atan,( 39560.32334));
2714 CHECK_DBL_SAME( atan,( +INFINITY));
2715 CHECK_DBL_SAME( atan,( -INFINITY));
2716 CHECK_DBL_SAME( atan,( +DBL_MAX));
2717 CHECK_DBL_SAME( atan,( -DBL_MAX));
2718 CHECK_DBL_SAME( atan,(2.34960584706e100));
2719 CHECK_DBL_SAME( atan,(2.34960584706e300));
2720 CHECK_DBL_SAME( atan,(2.34960584706e300));
2721 CHECK_DBL_SAME( atan,(RTStrNanDouble(NULL, true)));
2722 CHECK_DBL_SAME( atan,(RTStrNanDouble("s", true)));
2723 CHECK_DBL_SAME( atan,(RTStrNanDouble("s", false)));
2724
2725 CHECK_DBL(RT_NOCRT(atanf)( +1.0f), +0.78539816339744830962f /*+M_PI_4*/);
2726 CHECK_DBL(RT_NOCRT(atanf)( -1.0f), -0.78539816339744830962f /*-M_PI_4*/);
2727 CHECK_DBL(RT_NOCRT(atanf)( +INFINITY), +1.57079632679489661923f /*+M_PI_2*/);
2728 CHECK_DBL(RT_NOCRT(atanf)( -INFINITY), -1.57079632679489661923f /*-M_PI_2*/);
2729 CHECK_DBL_SAME( atanf,( 1.0f));
2730 CHECK_DBL_SAME( atanf,( 1.5f));
2731 CHECK_DBL_SAME( atanf,( +0.0f));
2732 CHECK_DBL_SAME( atanf,( +0.0f));
2733 CHECK_DBL_SAME( atanf,( -0.0f));
2734 CHECK_DBL_SAME( atanf,( -0.0f));
2735 CHECK_DBL_SAME( atanf,( 238.6634566f));
2736 CHECK_DBL_SAME( atanf,( -49.4578999f));
2737 CHECK_DBL_SAME( atanf,( 999999.0f));
2738 CHECK_DBL_SAME( atanf,( -999999.0f));
2739 CHECK_DBL_SAME( atanf,( -999999.0f));
2740 CHECK_DBL_SAME( atanf,( 999999.0f));
2741 CHECK_DBL_SAME( atanf,( 39560.32334f));
2742 CHECK_DBL_SAME( atanf,( 39560.32334f));
2743 CHECK_DBL_SAME( atanf,( +INFINITY));
2744 CHECK_DBL_SAME( atanf,( -INFINITY));
2745 CHECK_DBL_SAME( atanf,( +FLT_MAX));
2746 CHECK_DBL_SAME( atanf,( -FLT_MAX));
2747 CHECK_DBL_SAME( atanf,(2.34960584706e+10f));
2748 CHECK_DBL_SAME( atanf,(2.34960584706e+30f));
2749 CHECK_DBL_SAME( atanf,(2.34960584706e+30f));
2750 CHECK_DBL_SAME( atanf,(RTStrNanDouble(NULL, true)));
2751 CHECK_DBL_SAME( atanf,(RTStrNanDouble("s", true)));
2752 CHECK_DBL_SAME( atanf,(RTStrNanDouble("s", false)));
2753
2754}
2755
2756
2757
2758
2759int main()
2760{
2761 RTEXITCODE rcExit = RTTestInitAndCreate("tstRTNoCrt-2", &g_hTest);
2762 if (rcExit != RTEXITCODE_SUCCESS)
2763 return rcExit;
2764
2765 /* Some preconditions: */
2766 RTFLOAT32U r32;
2767 r32.r = RTStrNanFloat("s", false);
2768 RTTEST_CHECK(g_hTest, RTFLOAT32U_IS_SIGNALLING_NAN(&r32));
2769 r32.r = RTStrNanFloat("q", false);
2770 RTTEST_CHECK(g_hTest, RTFLOAT32U_IS_QUIET_NAN(&r32));
2771 r32.r = RTStrNanFloat(NULL, false);
2772 RTTEST_CHECK(g_hTest, RTFLOAT32U_IS_QUIET_NAN(&r32));
2773
2774 RTFLOAT64U r64;
2775 r64.r = RTStrNanDouble("s", false);
2776 RTTEST_CHECK(g_hTest, RTFLOAT64U_IS_SIGNALLING_NAN(&r64));
2777 r64.r = RTStrNanDouble("q", false);
2778 RTTEST_CHECK(g_hTest, RTFLOAT64U_IS_QUIET_NAN(&r64));
2779 r64.r = RTStrNanDouble(NULL, false);
2780 RTTEST_CHECK(g_hTest, RTFLOAT64U_IS_QUIET_NAN(&r64));
2781
2782 /* stdlib.h (integer) */
2783 testAbs();
2784
2785 /* math.h */
2786 testFAbs();
2787 testCopySign();
2788 testFmax();
2789 testFmin();
2790 testIsInf();
2791 testIsNan();
2792 testIsFinite();
2793 testIsNormal();
2794 testFpClassify();
2795 testSignBit();
2796 testCeil();
2797 testFloor();
2798 testTrunc();
2799 testRound();
2800 testRInt();
2801 testLRound();
2802 testLLRound();
2803 testLRInt();
2804 testLLRInt();
2805
2806 testExp2();
2807 testLdExp();
2808 testFma();
2809 testRemainder();
2810 testLog();
2811 testSqRt();
2812
2813 testATan();
2814
2815#if 0
2816 ../common/math/atan2.asm \
2817 ../common/math/atan2f.asm \
2818 ../common/math/cos.asm \
2819 ../common/math/cosf.asm \
2820 ../common/math/cosl.asm \
2821 ../common/math/sin.asm \
2822 ../common/math/sinf.asm \
2823 ../common/math/tan.asm \
2824 ../common/math/tanf.asm \
2825
2826#endif
2827
2828 return RTTestSummaryAndDestroy(g_hTest);
2829}
2830
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