VirtualBox

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

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

IPRT/tstRTNoCrt-2: More tests. bugref:10261

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 62.2 KB
Line 
1/* $Id: tstRTNoCrt-2.cpp 96198 2022-08-14 01:05: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 <math.h>
36#include <float.h>
37#include <limits.h>
38
39#define IPRT_NO_CRT_FOR_3RD_PARTY
40#define IPRT_NOCRT_WITHOUT_MATH_CONSTANTS /* so we can include both the CRT one and our no-CRT header */
41#include <iprt/nocrt/math.h>
42#define IPRT_INCLUDED_nocrt_limits_h /* prevent our limits from being included */
43#include <iprt/nocrt/stdlib.h>
44
45#include <iprt/string.h>
46#include <iprt/test.h>
47
48
49/*********************************************************************************************************************************
50* Defined Constants And Macros *
51*********************************************************************************************************************************/
52/*
53 * Macros checking i n t e g e r returns.
54 */
55#define CHECK_INT(a_Expr, a_rcExpect) do { \
56 int const rcActual = (a_Expr); \
57 if (rcActual != (a_rcExpect)) \
58 RTTestFailed(g_hTest, "line %u: %s -> %d, expected %d", __LINE__, #a_Expr, rcActual, (a_rcExpect)); \
59 } while (0)
60
61#define CHECK_INT_SAME(a_Fn, a_Args) do { \
62 int const rcNoCrt = RT_NOCRT(a_Fn) a_Args; \
63 int const rcCrt = a_Fn a_Args; \
64 if (rcNoCrt != rcCrt) \
65 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %d; CRT => %d", __LINE__, #a_Fn, #a_Args, rcNoCrt, rcCrt); \
66 } while (0)
67
68
69/*
70 * Macros checking l o n g returns.
71 */
72#define CHECK_LONG(a_Expr, a_rcExpect) do { \
73 long const rcActual = (a_Expr); \
74 long const rcExpect = (a_rcExpect); \
75 if (rcActual != rcExpect) \
76 RTTestFailed(g_hTest, "line %u: %s -> %ld, expected %ld", __LINE__, #a_Expr, rcActual, rcExpect); \
77 } while (0)
78
79#define CHECK_LONG_SAME(a_Fn, a_Args) do { \
80 long const rcNoCrt = RT_NOCRT(a_Fn) a_Args; \
81 long const rcCrt = a_Fn a_Args; \
82 if (rcNoCrt != rcCrt) \
83 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %ld; CRT => %ld", __LINE__, #a_Fn, #a_Args, rcNoCrt, rcCrt); \
84 } while (0)
85
86
87/*
88 * Macros checking l o n g l o n g returns.
89 */
90#define CHECK_LLONG(a_Expr, a_rcExpect) do { \
91 long long const rcActual = (a_Expr); \
92 long long const rcExpect = (a_rcExpect); \
93 if (rcActual != rcExpect) \
94 RTTestFailed(g_hTest, "line %u: %s -> %lld, expected %lld", __LINE__, #a_Expr, rcActual, rcExpect); \
95 } while (0)
96
97#define CHECK_LLONG_SAME(a_Fn, a_Args) do { \
98 long long const rcNoCrt = RT_NOCRT(a_Fn) a_Args; \
99 long long const rcCrt = a_Fn a_Args; \
100 if (rcNoCrt != rcCrt) \
101 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %lld; CRT => %lld", __LINE__, #a_Fn, #a_Args, rcNoCrt, rcCrt); \
102 } while (0)
103
104
105/*
106 * Macros checking l o n g d o u b l e returns.
107 */
108#ifdef RT_COMPILER_WITH_80BIT_LONG_DOUBLE
109# define CHECK_LDBL(a_Expr, a_lrdExpect) do { \
110 RTFLOAT80U2 uRet; \
111 uRet.r = (a_Expr); \
112 RTFLOAT80U2 uExpect; \
113 uExpect.r = a_lrdExpect; \
114 if (!RTFLOAT80U_ARE_IDENTICAL(&uRet, &uExpect)) \
115 { \
116 RTStrFormatR80u2(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
117 RTStrFormatR80u2(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
118 RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
119 __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_lrdExpect); \
120 } \
121 } while (0)
122
123# define CHECK_LDBL_SAME(a_Fn, a_Args) do { \
124 RTFLOAT80U2 uNoCrtRet, uCrtRet; \
125 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
126 uCrtRet.r = a_Fn a_Args; \
127 if (!RTFLOAT80U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
128 { \
129 RTStrFormatR80u2(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
130 RTStrFormatR80u2(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
131 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
132 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
133 } \
134 } while (0)
135
136# define CHECK_LDBL_APPROX_SAME(a_Fn, a_Args) do { \
137 RTFLOAT80U2 uNoCrtRet, uCrtRet; \
138 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
139 uCrtRet.r = a_Fn a_Args; \
140 if ( !RTFLOAT80U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
141 && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
142 || RTFLOAT80U_IS_NAN(&uNoCrtRet) \
143 || RTFLOAT80U_IS_NAN(&uCrtRet) ) ) \
144 { \
145 RTStrFormatR80u2(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
146 RTStrFormatR80u2(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
147 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
148 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
149 } \
150 } while (0)
151#elif defined(RT_COMPILER_WITH_128BIT_LONG_DOUBLE)
152# error todo
153#else
154# define CHECK_LDBL(a_Expr, a_lrdExpect) do { \
155 RTFLOAT64U uRet; \
156 uRet.lrd = (a_Expr); \
157 RTFLOAT64U uExpect; \
158 uExpect.lrd = a_lrdExpect; \
159 if (!RTFLOAT64U_ARE_IDENTICAL(&uRet, &uExpect)) \
160 { \
161 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
162 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
163 RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
164 __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_lrdExpect); \
165 } \
166 } while (0)
167
168#define CHECK_LDBL_SAME(a_Fn, a_Args) do { \
169 RTFLOAT64U uNoCrtRet, uCrtRet; \
170 uNoCrtRet.lrd = RT_NOCRT(a_Fn) a_Args; \
171 uCrtRet.lrd = a_Fn a_Args; \
172 if (!RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
173 { \
174 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
175 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
176 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
177 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
178 } \
179 } while (0)
180
181#define CHECK_LDBL_APPROX_SAME(a_Fn, a_Args) do { \
182 RTFLOAT64U uNoCrtRet, uCrtRet; \
183 uNoCrtRet.lrd = RT_NOCRT(a_Fn) a_Args; \
184 uCrtRet.lrd = a_Fn a_Args; \
185 if ( !RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
186 && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
187 || RTFLOAT64U_IS_NAN(&uNoCrtRet) \
188 || RTFLOAT64U_IS_NAN(&uCrtRet) ) ) \
189 { \
190 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
191 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
192 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
193 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
194 } \
195 } while (0)
196#endif
197
198
199/*
200 * Macros checking d o u b l e returns.
201 */
202#define CHECK_DBL(a_Expr, a_rdExpect) do { \
203 RTFLOAT64U uRet; \
204 uRet.r = (a_Expr); \
205 RTFLOAT64U uExpect; \
206 uExpect.r = a_rdExpect; \
207 if (!RTFLOAT64U_ARE_IDENTICAL(&uRet, &uExpect)) \
208 { \
209 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
210 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
211 RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
212 __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_rdExpect); \
213 } \
214 } while (0)
215
216#define CHECK_DBL_SAME(a_Fn, a_Args) do { \
217 RTFLOAT64U uNoCrtRet, uCrtRet; \
218 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
219 uCrtRet.r = a_Fn a_Args; \
220 if (!RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
221 { \
222 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
223 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
224 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
225 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
226 } \
227 } while (0)
228
229#define CHECK_DBL_APPROX_SAME(a_Fn, a_Args) do { \
230 RTFLOAT64U uNoCrtRet, uCrtRet; \
231 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
232 uCrtRet.r = a_Fn a_Args; \
233 if ( !RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
234 && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
235 || RTFLOAT64U_IS_NAN(&uNoCrtRet) \
236 || RTFLOAT64U_IS_NAN(&uCrtRet) ) ) \
237 { \
238 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
239 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
240 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
241 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
242 } \
243 } while (0)
244
245/*
246 * Macros checking f l o a t returns.
247 */
248#define CHECK_FLT(a_Expr, a_rExpect) do { \
249 RTFLOAT32U uRet; \
250 uRet.r = (a_Expr); \
251 RTFLOAT32U uExpect; \
252 uExpect.r = a_rExpect; \
253 if (!RTFLOAT32U_ARE_IDENTICAL(&uRet, &uExpect)) \
254 { \
255 RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
256 RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
257 RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
258 __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_rExpect); \
259 } \
260 } while (0)
261
262#define CHECK_FLT_SAME(a_Fn, a_Args) do { \
263 RTFLOAT32U uNoCrtRet, uCrtRet; \
264 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
265 uCrtRet.r = a_Fn a_Args; \
266 if (!RTFLOAT32U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
267 { \
268 RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
269 RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
270 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
271 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
272 } \
273 } while (0)
274
275#define CHECK_FLT_APPROX_SAME(a_Fn, a_Args) do { \
276 RTFLOAT32U uNoCrtRet, uCrtRet; \
277 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
278 uCrtRet.r = a_Fn a_Args; \
279 if ( !RTFLOAT32U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
280 && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
281 || RTFLOAT32U_IS_NAN(&uNoCrtRet) \
282 || RTFLOAT32U_IS_NAN(&uCrtRet) ) ) \
283 { \
284 RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
285 RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
286 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
287 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
288 } \
289 } while (0)
290
291
292/*********************************************************************************************************************************
293* Global Variables *
294*********************************************************************************************************************************/
295RTTEST g_hTest;
296char g_szFloat[2][128];
297
298
299void testAbs()
300{
301 RTTestSub(g_hTest, "abs,labs,llabs");
302 CHECK_INT(RT_NOCRT(abs)(1), 1);
303 CHECK_INT(RT_NOCRT(abs)(-1), 1);
304 CHECK_INT(RT_NOCRT(abs)(9685), 9685);
305 CHECK_INT(RT_NOCRT(abs)(-9685), 9685);
306 CHECK_INT(RT_NOCRT(abs)(589685), 589685);
307 CHECK_INT(RT_NOCRT(abs)(-589685), 589685);
308 CHECK_INT(RT_NOCRT(abs)(INT_MAX), INT_MAX);
309 CHECK_INT(RT_NOCRT(abs)(INT_MIN + 1), INT_MAX);
310 CHECK_INT(RT_NOCRT(abs)(INT_MIN), INT_MIN); /* oddity */
311 CHECK_INT_SAME(abs,(INT_MIN));
312 CHECK_INT_SAME(abs,(INT_MAX));
313
314 CHECK_LONG(RT_NOCRT(labs)(1), 1);
315 CHECK_LONG(RT_NOCRT(labs)(-1), 1);
316 CHECK_LONG(RT_NOCRT(labs)(9685), 9685);
317 CHECK_LONG(RT_NOCRT(labs)(-9685), 9685);
318 CHECK_LONG(RT_NOCRT(labs)(589685), 589685);
319 CHECK_LONG(RT_NOCRT(labs)(-589685), 589685);
320 CHECK_LONG(RT_NOCRT(labs)(LONG_MAX), LONG_MAX);
321 CHECK_LONG(RT_NOCRT(labs)(LONG_MIN + 1), LONG_MAX);
322 CHECK_LONG(RT_NOCRT(labs)(LONG_MIN), LONG_MIN); /* oddity */
323 CHECK_LONG_SAME(labs,(LONG_MIN));
324 CHECK_LONG_SAME(labs,(LONG_MAX));
325
326 CHECK_LONG(RT_NOCRT(llabs)(1), 1);
327 CHECK_LONG(RT_NOCRT(llabs)(-1), 1);
328 CHECK_LONG(RT_NOCRT(llabs)(9685), 9685);
329 CHECK_LONG(RT_NOCRT(llabs)(-9685), 9685);
330 CHECK_LONG(RT_NOCRT(llabs)(589685), 589685);
331 CHECK_LONG(RT_NOCRT(llabs)(-589685), 589685);
332 CHECK_LONG(RT_NOCRT(llabs)(LONG_MAX), LONG_MAX);
333 CHECK_LONG(RT_NOCRT(llabs)(LONG_MIN + 1), LONG_MAX);
334 CHECK_LONG(RT_NOCRT(llabs)(LONG_MIN), LONG_MIN); /* oddity */
335 CHECK_LONG_SAME(llabs,(LONG_MIN));
336 CHECK_LONG_SAME(llabs,(LONG_MAX));
337}
338
339
340void testCopySign()
341{
342 RTTestSub(g_hTest, "copysign[fl]");
343
344 CHECK_DBL(RT_NOCRT(copysign)(1.0, 2.0), 1.0);
345 CHECK_DBL(RT_NOCRT(copysign)(-1.0, 2.0), 1.0);
346 CHECK_DBL(RT_NOCRT(copysign)(-1.0, -2.0), -1.0);
347 CHECK_DBL(RT_NOCRT(copysign)(1.0, -2.0), -1.0);
348 CHECK_DBL(RT_NOCRT(copysign)(42.24, -INFINITY), -42.24);
349 CHECK_DBL(RT_NOCRT(copysign)(-42.24, +INFINITY), +42.24);
350 CHECK_DBL(RT_NOCRT(copysign)(-999888777.666, RTStrNanDouble(NULL, true)), +999888777.666);
351 CHECK_DBL(RT_NOCRT(copysign)(-999888777.666, RTStrNanDouble("sig", true)), +999888777.666);
352 CHECK_DBL(RT_NOCRT(copysign)(+999888777.666, RTStrNanDouble(NULL, false)), -999888777.666);
353 CHECK_DBL_SAME(copysign,(1.0, 2.0));
354 CHECK_DBL_SAME(copysign,(-1.0, 2.0));
355 CHECK_DBL_SAME(copysign,(-1.0, -2.0));
356 CHECK_DBL_SAME(copysign,(1.0, -2.0));
357 CHECK_DBL_SAME(copysign,(42.24, -INFINITY));
358 CHECK_DBL_SAME(copysign,(-42.24, +INFINITY));
359 CHECK_DBL_SAME(copysign,(-999888777.666, RTStrNanDouble(NULL, true)));
360 CHECK_DBL_SAME(copysign,(+999888777.666, RTStrNanDouble(NULL, false)));
361 CHECK_DBL_SAME(copysign,(+999888777.666, RTStrNanDouble("sig", false)));
362
363 CHECK_FLT(RT_NOCRT(copysignf)(1.0f, 2.0f), 1.0f);
364 CHECK_FLT(RT_NOCRT(copysignf)(-1.0f, 2.0f), 1.0f);
365 CHECK_FLT(RT_NOCRT(copysignf)(-1.0f, -2.0f), -1.0f);
366 CHECK_FLT(RT_NOCRT(copysignf)(1.0f, -2.0f), -1.0f);
367 CHECK_FLT(RT_NOCRT(copysignf)(42.24f, -INFINITY), -42.24f);
368 CHECK_FLT(RT_NOCRT(copysignf)(-42.24f, +INFINITY), +42.24f);
369 CHECK_FLT(RT_NOCRT(copysignf)(-999888777.666f, RTStrNanFloat(NULL, true)), +999888777.666f);
370 CHECK_FLT(RT_NOCRT(copysignf)(+999888777.666f, RTStrNanFloat(NULL, false)), -999888777.666f);
371 CHECK_FLT_SAME(copysignf,(1.0f, 2.0f));
372 CHECK_FLT_SAME(copysignf,(-3.0f, 2.0f));
373 CHECK_FLT_SAME(copysignf,(-5.0e3f, -2.0f));
374 CHECK_FLT_SAME(copysignf,(6.0e-3f, -2.0f));
375 CHECK_FLT_SAME(copysignf,(434.24f, -INFINITY));
376 CHECK_FLT_SAME(copysignf,(-42.24f, +INFINITY));
377 CHECK_FLT_SAME(copysignf,(-39480.6e+33f, RTStrNanFloat(NULL, true)));
378 CHECK_FLT_SAME(copysignf,(+39480.6e-32f, RTStrNanFloat(NULL, false)));
379
380 CHECK_LDBL(RT_NOCRT(copysignl)(1.0L, 2.0L), 1.0L);
381 CHECK_LDBL(RT_NOCRT(copysignl)(-1.0L, 2.0L), 1.0L);
382 CHECK_LDBL(RT_NOCRT(copysignl)(-1.0L, -2.0L), -1.0L);
383 CHECK_LDBL(RT_NOCRT(copysignl)(1.0L, -2.0L), -1.0L);
384 CHECK_LDBL(RT_NOCRT(copysignl)(42.24L, -INFINITY), -42.24L);
385 CHECK_LDBL(RT_NOCRT(copysignl)(-42.24L, +INFINITY), +42.24L);
386 CHECK_LDBL(RT_NOCRT(copysignl)(-999888777.666L, RTStrNanLongDouble(NULL, true)), +999888777.666L);
387 CHECK_LDBL(RT_NOCRT(copysignl)(+999888777.666L, RTStrNanLongDouble("2343f_sig", false)), -999888777.666L);
388 CHECK_LDBL_SAME(copysignl,(1.0L, 2.0L));
389 CHECK_LDBL_SAME(copysignl,(-3.0L, 2.0L));
390 CHECK_LDBL_SAME(copysignl,(-5.0e3L, -2.0L));
391 CHECK_LDBL_SAME(copysignl,(6.0e-3L, -2.0L));
392 CHECK_LDBL_SAME(copysignl,(434.24L, -INFINITY));
393 CHECK_LDBL_SAME(copysignl,(-42.24L, +INFINITY));
394 CHECK_LDBL_SAME(copysignl,(-39480.6e+33L, RTStrNanLongDouble("8888_s", true)));
395 CHECK_LDBL_SAME(copysignl,(+39480.6e-32L, RTStrNanLongDouble(NULL, false)));
396}
397
398
399void testExp2()
400{
401 RTTestSub(g_hTest, "exp2[f]");
402
403 CHECK_DBL(RT_NOCRT(exp2)(1.0), 2.0);
404 CHECK_DBL(RT_NOCRT(exp2)(2.0), 4.0);
405 CHECK_DBL(RT_NOCRT(exp2)(32.0), 4294967296.0);
406 CHECK_DBL(RT_NOCRT(exp2)(-1.0), 0.5);
407 CHECK_DBL(RT_NOCRT(exp2)(-3.0), 0.125);
408 CHECK_DBL_SAME(exp2, (0.0));
409 CHECK_DBL_SAME(exp2, (+INFINITY));
410 CHECK_DBL_SAME(exp2, (-INFINITY));
411 CHECK_DBL_SAME(exp2, (nan("1")));
412 CHECK_DBL_SAME(exp2, (RTStrNanDouble("ab305f", true)));
413 CHECK_DBL_SAME(exp2, (RTStrNanDouble("fffffffff_signaling", true)));
414 CHECK_DBL_SAME(exp2, (RTStrNanDouble("7777777777778_sig", false)));
415 CHECK_DBL_SAME(exp2, (1.0));
416 CHECK_DBL_SAME(exp2, (2.0));
417 CHECK_DBL_SAME(exp2, (-1.0));
418 CHECK_DBL_APPROX_SAME(exp2, (+0.5));
419 CHECK_DBL_APPROX_SAME(exp2, (-0.5));
420 CHECK_DBL_APPROX_SAME(exp2, (+1.5));
421 CHECK_DBL_APPROX_SAME(exp2, (-1.5));
422 CHECK_DBL_APPROX_SAME(exp2, (+3.25));
423 CHECK_DBL_APPROX_SAME(exp2, (99.2559430));
424 CHECK_DBL_APPROX_SAME(exp2, (-99.2559430));
425 CHECK_DBL_APPROX_SAME(exp2, (+305.2559430));
426 CHECK_DBL_APPROX_SAME(exp2, (-305.2559430));
427 CHECK_DBL_APPROX_SAME(exp2, (+309.99884));
428 CHECK_DBL_APPROX_SAME(exp2, (-309.111048));
429 CHECK_DBL_APPROX_SAME(exp2, (+999.864597634));
430 CHECK_DBL_APPROX_SAME(exp2, (-999.098234837));
431
432
433 CHECK_FLT(RT_NOCRT(exp2f)(1.0f), 2.0f);
434 CHECK_FLT(RT_NOCRT(exp2f)(2.0f), 4.0f);
435 CHECK_FLT(RT_NOCRT(exp2f)(32.0f), 4294967296.0f);
436 CHECK_FLT(RT_NOCRT(exp2f)(-1.0f), 0.5f);
437 CHECK_FLT(RT_NOCRT(exp2f)(-3.0f), 0.125f);
438 CHECK_FLT_SAME(exp2f, (0.0f));
439 CHECK_FLT_SAME(exp2f, (+INFINITY));
440 CHECK_FLT_SAME(exp2f, (-INFINITY));
441 CHECK_FLT_SAME(exp2f, (nan("1")));
442 CHECK_FLT_SAME(exp2f, (RTStrNanFloat("ab305f", true)));
443 CHECK_FLT_SAME(exp2f, (RTStrNanFloat("3fffff_signaling", true)));
444 CHECK_FLT_SAME(exp2f, (RTStrNanFloat("79778_sig", false)));
445 CHECK_FLT_SAME(exp2f, (1.0f));
446 CHECK_FLT_SAME(exp2f, (2.0f));
447 CHECK_FLT_SAME(exp2f, (-1.0f));
448 CHECK_FLT_APPROX_SAME(exp2f, (+0.5f));
449 CHECK_FLT_APPROX_SAME(exp2f, (-0.5f));
450 CHECK_FLT_APPROX_SAME(exp2f, (+1.5f));
451 CHECK_FLT_APPROX_SAME(exp2f, (-1.5f));
452 CHECK_FLT_APPROX_SAME(exp2f, (+3.25f));
453 CHECK_FLT_APPROX_SAME(exp2f, (99.25594f));
454 CHECK_FLT_APPROX_SAME(exp2f, (-99.25594f));
455 CHECK_FLT_APPROX_SAME(exp2f, (+305.25594f));
456 CHECK_FLT_APPROX_SAME(exp2f, (-305.25594f));
457 CHECK_FLT_APPROX_SAME(exp2f, (+309.99884f));
458 CHECK_FLT_APPROX_SAME(exp2f, (-309.111048f));
459 CHECK_FLT_APPROX_SAME(exp2f, (+999.86459f));
460 CHECK_FLT_APPROX_SAME(exp2f, (-999.09823f));
461}
462
463
464void testFma()
465{
466 RTTestSub(g_hTest, "fma[f]");
467
468 CHECK_DBL(RT_NOCRT(fma)(1.0, 1.0, 1.0), 2.0);
469 CHECK_DBL(RT_NOCRT(fma)(4.0, 2.0, 1.0), 9.0);
470 CHECK_DBL(RT_NOCRT(fma)(4.0, 2.0, -1.0), 7.0);
471 CHECK_DBL_SAME(fma, (0.0, 0.0, 0.0));
472 CHECK_DBL_SAME(fma, (999999.0, 33334.0, 29345.0));
473 CHECK_DBL_SAME(fma, (39560.32334, 9605.5546, -59079.345069));
474 CHECK_DBL_SAME(fma, (39560.32334, -59079.345069, 9605.5546));
475 CHECK_DBL_SAME(fma, (-59079.345069, 39560.32334, 9605.5546));
476 CHECK_DBL_SAME(fma, (+INFINITY, +INFINITY, -INFINITY));
477 CHECK_DBL_SAME(fma, (4.0, +INFINITY, 2.0));
478 CHECK_DBL_SAME(fma, (4.0, 4.0, +INFINITY));
479 CHECK_DBL_SAME(fma, (-INFINITY, 4.0, 4.0));
480 CHECK_DBL_SAME(fma, (2.34960584706e100, 7.6050698459e-13, 9.99996777e77));
481
482 CHECK_FLT(RT_NOCRT(fmaf)(1.0f, 1.0f, 1.0), 2.0);
483 CHECK_FLT(RT_NOCRT(fmaf)(4.0f, 2.0f, 1.0), 9.0);
484 CHECK_FLT(RT_NOCRT(fmaf)(4.0f, 2.0f, -1.0), 7.0);
485 CHECK_FLT_SAME(fmaf, (0.0f, 0.0f, 0.0f));
486 CHECK_FLT_SAME(fmaf, (999999.0f, 33334.0f, 29345.0f));
487 CHECK_FLT_SAME(fmaf, (39560.32334f, 9605.5546f, -59079.345069f));
488 CHECK_FLT_SAME(fmaf, (39560.32334f, -59079.345069f, 9605.5546f));
489 CHECK_FLT_SAME(fmaf, (-59079.345069f, 39560.32334f, 9605.5546f));
490 CHECK_FLT_SAME(fmaf, (+INFINITY, +INFINITY, -INFINITY));
491 CHECK_FLT_SAME(fmaf, (4.0f, +INFINITY, 2.0f));
492 CHECK_FLT_SAME(fmaf, (4.0f, 4.0f, +INFINITY));
493 CHECK_FLT_SAME(fmaf, (-INFINITY, 4.0f, 4.0f));
494 CHECK_FLT_SAME(fmaf, (2.34960584706e22f, 7.6050698459e-13f, 9.99996777e27f));
495}
496
497
498void testFmax()
499{
500 RTTestSub(g_hTest, "fmax[fl]");
501
502 CHECK_DBL(RT_NOCRT(fmax)( 1.0, 1.0), 1.0);
503 CHECK_DBL(RT_NOCRT(fmax)( 4.0, 2.0), 4.0);
504 CHECK_DBL(RT_NOCRT(fmax)( 2.0, 4.0), 4.0);
505 CHECK_DBL(RT_NOCRT(fmax)(-2.0, -4.0), -2.0);
506 CHECK_DBL(RT_NOCRT(fmax)(-2.0, -4.0e-10), -4.0e-10);
507 CHECK_DBL(RT_NOCRT(fmax)(+INFINITY, +INFINITY), +INFINITY);
508 CHECK_DBL(RT_NOCRT(fmax)(-INFINITY, -INFINITY), -INFINITY);
509 CHECK_DBL(RT_NOCRT(fmax)(+INFINITY, -INFINITY), +INFINITY);
510 CHECK_DBL(RT_NOCRT(fmax)(-INFINITY, +INFINITY), +INFINITY);
511 CHECK_DBL_SAME(fmax, ( 99.99, 99.87));
512 CHECK_DBL_SAME(fmax, ( -99.99, -99.87));
513 CHECK_DBL_SAME(fmax, (-987.453, 34599.87));
514 CHECK_DBL_SAME(fmax, (34599.87, -987.453));
515 CHECK_DBL_SAME(fmax, ( +0.0, -0.0));
516 CHECK_DBL_SAME(fmax, ( -0.0, +0.0));
517 CHECK_DBL_SAME(fmax, ( -0.0, -0.0));
518 CHECK_DBL_SAME(fmax, (+INFINITY, +INFINITY));
519 CHECK_DBL_SAME(fmax, (-INFINITY, -INFINITY));
520 CHECK_DBL_SAME(fmax, (+INFINITY, -INFINITY));
521 CHECK_DBL_SAME(fmax, (-INFINITY, +INFINITY));
522 CHECK_DBL_SAME(fmax, (RTStrNanDouble(NULL, true), -42.4242424242e222));
523 CHECK_DBL_SAME(fmax, (RTStrNanDouble(NULL, false), -42.4242424242e222));
524 CHECK_DBL_SAME(fmax, (-42.4242424242e-222, RTStrNanDouble(NULL, true)));
525 CHECK_DBL_SAME(fmax, (-42.4242424242e-222, RTStrNanDouble(NULL, false)));
526 CHECK_DBL_SAME(fmax, (RTStrNanDouble("2", false), RTStrNanDouble(NULL, false)));
527 CHECK_DBL_SAME(fmax, (RTStrNanDouble("3", true), RTStrNanDouble(NULL, false)));
528 CHECK_DBL_SAME(fmax, (RTStrNanDouble("4sig", true), RTStrNanDouble(NULL, false)));
529
530 CHECK_FLT(RT_NOCRT(fmaxf)( 1.0f, 1.0f), 1.0f);
531 CHECK_FLT(RT_NOCRT(fmaxf)( 4.0f, 2.0f), 4.0f);
532 CHECK_FLT(RT_NOCRT(fmaxf)( 2.0f, 4.0f), 4.0f);
533 CHECK_FLT(RT_NOCRT(fmaxf)(-2.0f, -4.0f), -2.0f);
534 CHECK_FLT(RT_NOCRT(fmaxf)(-2.0f, -4.0e-10f), -4.0e-10f);
535 CHECK_FLT(RT_NOCRT(fmaxf)(+INFINITY, +INFINITY), +INFINITY);
536 CHECK_FLT(RT_NOCRT(fmaxf)(-INFINITY, -INFINITY), -INFINITY);
537 CHECK_FLT(RT_NOCRT(fmaxf)(+INFINITY, -INFINITY), +INFINITY);
538 CHECK_FLT(RT_NOCRT(fmaxf)(-INFINITY, +INFINITY), +INFINITY);
539 CHECK_FLT_SAME(fmaxf, ( 99.99f, 99.87f));
540 CHECK_FLT_SAME(fmaxf, ( -99.99f, -99.87f));
541 CHECK_FLT_SAME(fmaxf, (-987.453f, 34599.87f));
542 CHECK_FLT_SAME(fmaxf, (34599.87f, -987.453f));
543 CHECK_FLT_SAME(fmaxf, ( +0.0f, -0.0f));
544 CHECK_FLT_SAME(fmaxf, ( -0.0f, +0.0f));
545 CHECK_FLT_SAME(fmaxf, ( -0.0f, -0.0f));
546 CHECK_FLT_SAME(fmaxf, (+INFINITY, +INFINITY));
547 CHECK_FLT_SAME(fmaxf, (-INFINITY, -INFINITY));
548 CHECK_FLT_SAME(fmaxf, (+INFINITY, -INFINITY));
549 CHECK_FLT_SAME(fmaxf, (-INFINITY, +INFINITY));
550 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat(NULL, true), -42.4242424242e22f));
551 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat(NULL, false), -42.4242424242e22f));
552 CHECK_FLT_SAME(fmaxf, (-42.42424242e-22f, RTStrNanFloat(NULL, true)));
553 CHECK_FLT_SAME(fmaxf, (-42.42424242e-22f, RTStrNanFloat(NULL, false)));
554 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat("2", false), RTStrNanFloat(NULL, false)));
555 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat("3", true), RTStrNanFloat(NULL, false)));
556 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat("4sig", true), RTStrNanFloat(NULL, false)));
557
558 CHECK_LDBL(RT_NOCRT(fmaxl)( 1.0L, 1.0L), 1.0L);
559 CHECK_LDBL(RT_NOCRT(fmaxl)( 4.0L, 2.0L), 4.0L);
560 CHECK_LDBL(RT_NOCRT(fmaxl)( 2.0L, 4.0L), 4.0L);
561 CHECK_LDBL(RT_NOCRT(fmaxl)(-2.0L, -4.0L), -2.0L);
562 CHECK_LDBL(RT_NOCRT(fmaxl)(-2.0L, -4.0e-10L), -4.0e-10L);
563 CHECK_LDBL(RT_NOCRT(fmaxl)(+INFINITY, +INFINITY), +INFINITY);
564 CHECK_LDBL(RT_NOCRT(fmaxl)(-INFINITY, -INFINITY), -INFINITY);
565 CHECK_LDBL(RT_NOCRT(fmaxl)(+INFINITY, -INFINITY), +INFINITY);
566 CHECK_LDBL(RT_NOCRT(fmaxl)(-INFINITY, +INFINITY), +INFINITY);
567 CHECK_LDBL_SAME(fmaxl, ( 99.99L, 99.87L));
568 CHECK_LDBL_SAME(fmaxl, ( -99.99L, -99.87L));
569 CHECK_LDBL_SAME(fmaxl, (-987.453L, 34599.87L));
570 CHECK_LDBL_SAME(fmaxl, (34599.87L, -987.453L));
571 CHECK_LDBL_SAME(fmaxl, ( +0.0L, -0.0L));
572 CHECK_LDBL_SAME(fmaxl, ( -0.0L, +0.0L));
573 CHECK_LDBL_SAME(fmaxl, ( -0.0L, -0.0L));
574 CHECK_LDBL_SAME(fmaxl, (+INFINITY, +INFINITY));
575 CHECK_LDBL_SAME(fmaxl, (-INFINITY, -INFINITY));
576 CHECK_LDBL_SAME(fmaxl, (+INFINITY, -INFINITY));
577 CHECK_LDBL_SAME(fmaxl, (-INFINITY, +INFINITY));
578 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble(NULL, true), -42.4242424242e222L));
579 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble(NULL, false), -42.4242424242e222L));
580 CHECK_LDBL_SAME(fmaxl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, true)));
581 CHECK_LDBL_SAME(fmaxl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, false)));
582 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble("2", false), RTStrNanLongDouble(NULL, false)));
583 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble("3", true), RTStrNanLongDouble(NULL, false)));
584 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble("4sig", true), RTStrNanLongDouble(NULL, false)));
585}
586
587
588void testFmin()
589{
590 RTTestSub(g_hTest, "fmin[fl]");
591
592 CHECK_DBL(RT_NOCRT(fmin)( 1.0, 1.0), 1.0);
593 CHECK_DBL(RT_NOCRT(fmin)( 4.0, 2.0), 2.0);
594 CHECK_DBL(RT_NOCRT(fmin)( 2.0, 4.0), 2.0);
595 CHECK_DBL(RT_NOCRT(fmin)(-2.0, -4.0), -4.0);
596 CHECK_DBL(RT_NOCRT(fmin)(-2.0, -4.0e+10), -4.0e+10);
597 CHECK_DBL(RT_NOCRT(fmin)(+INFINITY, +INFINITY), +INFINITY);
598 CHECK_DBL(RT_NOCRT(fmin)(-INFINITY, -INFINITY), -INFINITY);
599 CHECK_DBL(RT_NOCRT(fmin)(+INFINITY, -INFINITY), -INFINITY);
600 CHECK_DBL(RT_NOCRT(fmin)(-INFINITY, +INFINITY), -INFINITY);
601 CHECK_DBL_SAME(fmin, ( 99.99, 99.87));
602 CHECK_DBL_SAME(fmin, ( -99.99, -99.87));
603 CHECK_DBL_SAME(fmin, (-987.453, 34599.87));
604 CHECK_DBL_SAME(fmin, (34599.87, -987.453));
605 CHECK_DBL_SAME(fmin, ( +0.0, -0.0));
606 CHECK_DBL_SAME(fmin, ( -0.0, +0.0));
607 CHECK_DBL_SAME(fmin, ( -0.0, -0.0));
608 CHECK_DBL_SAME(fmin, (+INFINITY, +INFINITY));
609 CHECK_DBL_SAME(fmin, (-INFINITY, -INFINITY));
610 CHECK_DBL_SAME(fmin, (+INFINITY, -INFINITY));
611 CHECK_DBL_SAME(fmin, (-INFINITY, +INFINITY));
612 CHECK_DBL_SAME(fmin, (RTStrNanDouble(NULL, true), -42.4242424242e222));
613 CHECK_DBL_SAME(fmin, (RTStrNanDouble(NULL, false), -42.4242424242e222));
614 CHECK_DBL_SAME(fmin, (-42.4242424242e-222, RTStrNanDouble(NULL, true)));
615 CHECK_DBL_SAME(fmin, (-42.4242424242e-222, RTStrNanDouble(NULL, false)));
616 CHECK_DBL_SAME(fmin, (RTStrNanDouble("2", false), RTStrNanDouble(NULL, false)));
617 CHECK_DBL_SAME(fmin, (RTStrNanDouble("3", true), RTStrNanDouble(NULL, false)));
618 CHECK_DBL_SAME(fmin, (RTStrNanDouble("4sig", true), RTStrNanDouble(NULL, false)));
619
620 CHECK_FLT(RT_NOCRT(fmin)( 1.0f, 1.0f), 1.0f);
621 CHECK_FLT(RT_NOCRT(fmin)( 4.0f, 2.0f), 2.0f);
622 CHECK_FLT(RT_NOCRT(fmin)( 2.0f, 4.0f), 2.0f);
623 CHECK_FLT(RT_NOCRT(fmin)(-2.0f, -4.0f), -4.0f);
624 CHECK_FLT(RT_NOCRT(fmin)(-2.0f, -4.0e+10f), -4.0e+10f);
625 CHECK_FLT(RT_NOCRT(fmin)(+INFINITY, +INFINITY), +INFINITY);
626 CHECK_FLT(RT_NOCRT(fmin)(-INFINITY, -INFINITY), -INFINITY);
627 CHECK_FLT(RT_NOCRT(fmin)(+INFINITY, -INFINITY), -INFINITY);
628 CHECK_FLT(RT_NOCRT(fmin)(-INFINITY, +INFINITY), -INFINITY);
629 CHECK_FLT_SAME(fminf, ( 99.99f, 99.87f));
630 CHECK_FLT_SAME(fminf, ( -99.99f, -99.87f));
631 CHECK_FLT_SAME(fminf, (-987.453f, 34599.87f));
632 CHECK_FLT_SAME(fminf, (34599.87f, -987.453f));
633 CHECK_FLT_SAME(fminf, ( +0.0f, -0.0f));
634 CHECK_FLT_SAME(fminf, ( -0.0f, +0.0f));
635 CHECK_FLT_SAME(fminf, ( -0.0f, -0.0f));
636 CHECK_FLT_SAME(fminf, (+INFINITY, +INFINITY));
637 CHECK_FLT_SAME(fminf, (-INFINITY, -INFINITY));
638 CHECK_FLT_SAME(fminf, (+INFINITY, -INFINITY));
639 CHECK_FLT_SAME(fminf, (-INFINITY, +INFINITY));
640 CHECK_FLT_SAME(fminf, (RTStrNanFloat(NULL, true), -42.4242424242e22f));
641 CHECK_FLT_SAME(fminf, (RTStrNanFloat(NULL, false), -42.4242424242e22f));
642 CHECK_FLT_SAME(fminf, (-42.42424242e-22f, RTStrNanFloat(NULL, true)));
643 CHECK_FLT_SAME(fminf, (-42.42424242e-22f, RTStrNanFloat(NULL, false)));
644 CHECK_FLT_SAME(fminf, (RTStrNanFloat("2", false), RTStrNanFloat(NULL, false)));
645 CHECK_FLT_SAME(fminf, (RTStrNanFloat("3", true), RTStrNanFloat(NULL, false)));
646 CHECK_FLT_SAME(fminf, (RTStrNanFloat("4sig", true), RTStrNanFloat(NULL, false)));
647
648 CHECK_LDBL(RT_NOCRT(fmin)( 1.0L, 1.0L), 1.0L);
649 CHECK_LDBL(RT_NOCRT(fmin)( 4.0L, 2.0L), 2.0L);
650 CHECK_LDBL(RT_NOCRT(fmin)( 2.0L, 4.0L), 2.0L);
651 CHECK_LDBL(RT_NOCRT(fmin)(-2.0L, -4.0L), -4.0L);
652 CHECK_LDBL(RT_NOCRT(fmin)(-2.0L, -4.0e+10L), -4.0e+10L);
653 CHECK_LDBL(RT_NOCRT(fmin)(+INFINITY, +INFINITY), +INFINITY);
654 CHECK_LDBL(RT_NOCRT(fmin)(-INFINITY, -INFINITY), -INFINITY);
655 CHECK_LDBL(RT_NOCRT(fmin)(+INFINITY, -INFINITY), -INFINITY);
656 CHECK_LDBL(RT_NOCRT(fmin)(-INFINITY, +INFINITY), -INFINITY);
657 CHECK_LDBL_SAME(fminl, ( 99.99L, 99.87L));
658 CHECK_LDBL_SAME(fminl, ( -99.99L, -99.87L));
659 CHECK_LDBL_SAME(fminl, (-987.453L, 34599.87L));
660 CHECK_LDBL_SAME(fminl, (34599.87L, -987.453L));
661 CHECK_LDBL_SAME(fminl, ( +0.0L, -0.0L));
662 CHECK_LDBL_SAME(fminl, ( -0.0L, +0.0L));
663 CHECK_LDBL_SAME(fminl, ( -0.0L, -0.0L));
664 CHECK_LDBL_SAME(fminl, (+INFINITY, +INFINITY));
665 CHECK_LDBL_SAME(fminl, (-INFINITY, -INFINITY));
666 CHECK_LDBL_SAME(fminl, (+INFINITY, -INFINITY));
667 CHECK_LDBL_SAME(fminl, (-INFINITY, +INFINITY));
668 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble(NULL, true), -42.4242424242e222L));
669 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble(NULL, false), -42.4242424242e222L));
670 CHECK_LDBL_SAME(fminl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, true)));
671 CHECK_LDBL_SAME(fminl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, false)));
672 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble("2", false), RTStrNanLongDouble(NULL, false)));
673 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble("3", true), RTStrNanLongDouble(NULL, false)));
674 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble("4sig", true), RTStrNanLongDouble(NULL, false)));
675}
676
677
678void testIsInf()
679{
680 RTTestSub(g_hTest, "isinf,__isinf[fl]");
681#undef isinf
682 CHECK_INT(RT_NOCRT(isinf)( 1.0), 0);
683 CHECK_INT(RT_NOCRT(isinf)( 2394.2340e200), 0);
684 CHECK_INT(RT_NOCRT(isinf)(-2394.2340e200), 0);
685 CHECK_INT(RT_NOCRT(isinf)(-INFINITY), 1);
686 CHECK_INT(RT_NOCRT(isinf)(+INFINITY), 1);
687 CHECK_INT(RT_NOCRT(isinf)(RTStrNanDouble(NULL, true)), 0);
688 CHECK_INT(RT_NOCRT(isinf)(RTStrNanDouble("4sig", false)), 0);
689
690 CHECK_INT(RT_NOCRT(__isinff)( 1.0f), 0);
691 CHECK_INT(RT_NOCRT(__isinff)( 2394.2340e20f), 0);
692 CHECK_INT(RT_NOCRT(__isinff)(-2394.2340e20f), 0);
693 CHECK_INT(RT_NOCRT(__isinff)(-INFINITY), 1);
694 CHECK_INT(RT_NOCRT(__isinff)(+INFINITY), 1);
695 CHECK_INT(RT_NOCRT(__isinff)(RTStrNanFloat(NULL, true)), 0);
696 CHECK_INT(RT_NOCRT(__isinff)(RTStrNanFloat("4sig", false)), 0);
697
698 CHECK_INT(RT_NOCRT(__isinfl)( 1.0L), 0);
699 CHECK_INT(RT_NOCRT(__isinfl)( 2394.2340e200L), 0);
700 CHECK_INT(RT_NOCRT(__isinfl)(-2394.2340e200L), 0);
701 CHECK_INT(RT_NOCRT(__isinfl)(-INFINITY), 1);
702 CHECK_INT(RT_NOCRT(__isinfl)(+INFINITY), 1);
703 CHECK_INT(RT_NOCRT(__isinfl)(RTStrNanLongDouble(NULL, true)), 0);
704 CHECK_INT(RT_NOCRT(__isinfl)(RTStrNanLongDouble("4sig", false)), 0);
705}
706
707
708void testIsNan()
709{
710 RTTestSub(g_hTest, "isnan[f],__isnanl");
711#undef isnan
712 CHECK_INT(RT_NOCRT(isnan)( 0.0), 0);
713 CHECK_INT(RT_NOCRT(isnan)( 1.0), 0);
714 CHECK_INT(RT_NOCRT(isnan)( 2394.2340e200), 0);
715 CHECK_INT(RT_NOCRT(isnan)(-2394.2340e200), 0);
716 CHECK_INT(RT_NOCRT(isnan)(-INFINITY), 0);
717 CHECK_INT(RT_NOCRT(isnan)(+INFINITY), 0);
718 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble(NULL, true)), 1);
719 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble(NULL, false)), 1);
720 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("435876quiet", false)), 1);
721 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("435876quiet", true)), 1);
722 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("678sig", false)), 1);
723 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("45547absig", true)), 1);
724
725 CHECK_INT(RT_NOCRT(isnanf)( 0.0f), 0);
726 CHECK_INT(RT_NOCRT(isnanf)( 1.0f), 0);
727 CHECK_INT(RT_NOCRT(isnanf)( 2394.2340e20f), 0);
728 CHECK_INT(RT_NOCRT(isnanf)(-2394.2340e20f), 0);
729 CHECK_INT(RT_NOCRT(isnanf)(-INFINITY), 0);
730 CHECK_INT(RT_NOCRT(isnanf)(+INFINITY), 0);
731 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat(NULL, true)), 1);
732 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat(NULL, false)), 1);
733 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("9560q", false)), 1);
734 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("aaaaq", true)), 1);
735 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("4sig", false)), 1);
736 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("69504sig", true)), 1);
737
738 CHECK_INT(RT_NOCRT(__isnanl)( 0.0L), 0);
739 CHECK_INT(RT_NOCRT(__isnanl)( 1.0L), 0);
740 CHECK_INT(RT_NOCRT(__isnanl)( 2394.2340e200L), 0);
741 CHECK_INT(RT_NOCRT(__isnanl)(-2394.2340e200L), 0);
742 CHECK_INT(RT_NOCRT(__isnanl)(-INFINITY), 0);
743 CHECK_INT(RT_NOCRT(__isnanl)(+INFINITY), 0);
744 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble(NULL, true)), 1);
745 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble(NULL, false)), 1);
746 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("bbbbq", false)), 1);
747 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("11122q", true)), 1);
748 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("4sig", false)), 1);
749 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("23423406sig", true)), 1);
750}
751
752
753void testIsFinite()
754{
755 RTTestSub(g_hTest, "__isfinite[fl]");
756 CHECK_INT(RT_NOCRT(__isfinite)( 1.0), 1);
757 CHECK_INT(RT_NOCRT(__isfinite)( 2394.2340e200), 1);
758 CHECK_INT(RT_NOCRT(__isfinite)(-2394.2340e200), 1);
759 CHECK_INT(RT_NOCRT(__isfinite)(-2.1984e-310), 1); /* subnormal */
760 CHECK_INT(RT_NOCRT(__isfinite)(-INFINITY), 0);
761 CHECK_INT(RT_NOCRT(__isfinite)(+INFINITY), 0);
762 CHECK_INT(RT_NOCRT(__isfinite)(RTStrNanDouble(NULL, true)), 0);
763 CHECK_INT(RT_NOCRT(__isfinite)(RTStrNanDouble("4sig", false)), 0);
764
765 CHECK_INT(RT_NOCRT(__isfinitef)( 1.0f), 1);
766 CHECK_INT(RT_NOCRT(__isfinitef)( 2394.2340e20f), 1);
767 CHECK_INT(RT_NOCRT(__isfinitef)(-2394.2340e20f), 1);
768 CHECK_INT(RT_NOCRT(__isfinitef)(-2.1984e-40f), 1); /* subnormal */
769 CHECK_INT(RT_NOCRT(__isfinitef)(-INFINITY), 0);
770 CHECK_INT(RT_NOCRT(__isfinitef)(+INFINITY), 0);
771 CHECK_INT(RT_NOCRT(__isfinitef)(RTStrNanFloat(NULL, true)), 0);
772 CHECK_INT(RT_NOCRT(__isfinitef)(RTStrNanFloat("4sig", false)), 0);
773
774 CHECK_INT(RT_NOCRT(__isfinitel)( 1.0L), 1);
775 CHECK_INT(RT_NOCRT(__isfinitel)( 2394.2340e200L), 1);
776 CHECK_INT(RT_NOCRT(__isfinitel)(-2394.2340e200L), 1);
777#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
778 CHECK_INT(RT_NOCRT(__isfinitel)(-2.1984e-310L), 1); /* subnormal */
779#else
780 CHECK_INT(RT_NOCRT(__isfinitel)(-2.1984e-4935L), 1); /* subnormal */
781#endif
782 CHECK_INT(RT_NOCRT(__isfinitel)(-INFINITY), 0);
783 CHECK_INT(RT_NOCRT(__isfinitel)(+INFINITY), 0);
784 CHECK_INT(RT_NOCRT(__isfinitel)(RTStrNanLongDouble(NULL, true)), 0);
785 CHECK_INT(RT_NOCRT(__isfinitel)(RTStrNanLongDouble("4sig", false)), 0);
786}
787
788
789void testIsNormal()
790{
791 RTTestSub(g_hTest, "__isnormal[fl]");
792 CHECK_INT(RT_NOCRT(__isnormal)( 1.0), 1);
793 CHECK_INT(RT_NOCRT(__isnormal)( 2394.2340e200), 1);
794 CHECK_INT(RT_NOCRT(__isnormal)(-2394.2340e200), 1);
795 CHECK_INT(RT_NOCRT(__isnormal)(-2.1984e-310), 0); /* subnormal */
796 CHECK_INT(RT_NOCRT(__isnormal)(-INFINITY), 0);
797 CHECK_INT(RT_NOCRT(__isnormal)(+INFINITY), 0);
798 CHECK_INT(RT_NOCRT(__isnormal)(RTStrNanDouble(NULL, true)), 0);
799 CHECK_INT(RT_NOCRT(__isnormal)(RTStrNanDouble("4sig", false)), 0);
800
801 CHECK_INT(RT_NOCRT(__isnormalf)( 1.0f), 1);
802 CHECK_INT(RT_NOCRT(__isnormalf)( 2394.2340e20f), 1);
803 CHECK_INT(RT_NOCRT(__isnormalf)(-2394.2340e20f), 1);
804 CHECK_INT(RT_NOCRT(__isnormalf)(-2.1984e-40f), 0); /* subnormal */
805 CHECK_INT(RT_NOCRT(__isnormalf)(-INFINITY), 0);
806 CHECK_INT(RT_NOCRT(__isnormalf)(+INFINITY), 0);
807 CHECK_INT(RT_NOCRT(__isnormalf)(RTStrNanFloat(NULL, true)), 0);
808 CHECK_INT(RT_NOCRT(__isnormalf)(RTStrNanFloat("4sig", false)), 0);
809
810 CHECK_INT(RT_NOCRT(__isnormall)( 1.0L), 1);
811 CHECK_INT(RT_NOCRT(__isnormall)( 2394.2340e200L), 1);
812 CHECK_INT(RT_NOCRT(__isnormall)(-2394.2340e200L), 1);
813#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
814 CHECK_INT(RT_NOCRT(__isnormall)(-2.1984e-310L), 0); /* subnormal */
815#else
816 CHECK_INT(RT_NOCRT(__isnormall)(-2.1984e-4935L), 0); /* subnormal */
817#endif
818 CHECK_INT(RT_NOCRT(__isnormall)(-INFINITY), 0);
819 CHECK_INT(RT_NOCRT(__isnormall)(+INFINITY), 0);
820 CHECK_INT(RT_NOCRT(__isnormall)(RTStrNanLongDouble(NULL, true)), 0);
821 CHECK_INT(RT_NOCRT(__isnormall)(RTStrNanLongDouble("4sig", false)), 0);
822}
823
824
825void testFpClassify()
826{
827 RTTestSub(g_hTest, "__fpclassify[dfl]");
828 CHECK_INT(RT_NOCRT(__fpclassifyd)( +0.0), RT_NOCRT_FP_ZERO);
829 CHECK_INT(RT_NOCRT(__fpclassifyd)( -0.0), RT_NOCRT_FP_ZERO);
830 CHECK_INT(RT_NOCRT(__fpclassifyd)( 1.0), RT_NOCRT_FP_NORMAL);
831 CHECK_INT(RT_NOCRT(__fpclassifyd)( 2394.2340e200), RT_NOCRT_FP_NORMAL);
832 CHECK_INT(RT_NOCRT(__fpclassifyd)(-2394.2340e200), RT_NOCRT_FP_NORMAL);
833 CHECK_INT(RT_NOCRT(__fpclassifyd)(-2.1984e-310), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
834 CHECK_INT(RT_NOCRT(__fpclassifyd)(-INFINITY), RT_NOCRT_FP_INFINITE);
835 CHECK_INT(RT_NOCRT(__fpclassifyd)(+INFINITY), RT_NOCRT_FP_INFINITE);
836 CHECK_INT(RT_NOCRT(__fpclassifyd)(RTStrNanDouble(NULL, true)), RT_NOCRT_FP_NAN);
837 CHECK_INT(RT_NOCRT(__fpclassifyd)(RTStrNanDouble("4sig", false)), RT_NOCRT_FP_NAN);
838
839 CHECK_INT(RT_NOCRT(__fpclassifyf)( +0.0f), RT_NOCRT_FP_ZERO);
840 CHECK_INT(RT_NOCRT(__fpclassifyf)( -0.0f), RT_NOCRT_FP_ZERO);
841 CHECK_INT(RT_NOCRT(__fpclassifyf)( 1.0f), RT_NOCRT_FP_NORMAL);
842 CHECK_INT(RT_NOCRT(__fpclassifyf)( 2394.2340e20f), RT_NOCRT_FP_NORMAL);
843 CHECK_INT(RT_NOCRT(__fpclassifyf)(-2394.2340e20f), RT_NOCRT_FP_NORMAL);
844 CHECK_INT(RT_NOCRT(__fpclassifyf)(-2.1984e-40f), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
845 CHECK_INT(RT_NOCRT(__fpclassifyf)(-INFINITY), RT_NOCRT_FP_INFINITE);
846 CHECK_INT(RT_NOCRT(__fpclassifyf)(+INFINITY), RT_NOCRT_FP_INFINITE);
847 CHECK_INT(RT_NOCRT(__fpclassifyf)(RTStrNanFloat(NULL, true)), RT_NOCRT_FP_NAN);
848 CHECK_INT(RT_NOCRT(__fpclassifyf)(RTStrNanFloat("4sig", false)), RT_NOCRT_FP_NAN);
849
850 CHECK_INT(RT_NOCRT(__fpclassifyl)( +0.0L), RT_NOCRT_FP_ZERO);
851 CHECK_INT(RT_NOCRT(__fpclassifyl)( -0.0L), RT_NOCRT_FP_ZERO);
852 CHECK_INT(RT_NOCRT(__fpclassifyl)( 1.0L), RT_NOCRT_FP_NORMAL);
853 CHECK_INT(RT_NOCRT(__fpclassifyl)( 2394.2340e200L), RT_NOCRT_FP_NORMAL);
854 CHECK_INT(RT_NOCRT(__fpclassifyl)(-2394.2340e200L), RT_NOCRT_FP_NORMAL);
855#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
856 CHECK_INT(RT_NOCRT(__fpclassifyl)(-2.1984e-310L), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
857#else
858 CHECK_INT(RT_NOCRT(__fpclassifyl)(-2.1984e-4935L), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
859#endif
860 CHECK_INT(RT_NOCRT(__fpclassifyl)(-INFINITY), RT_NOCRT_FP_INFINITE);
861 CHECK_INT(RT_NOCRT(__fpclassifyl)(+INFINITY), RT_NOCRT_FP_INFINITE);
862 CHECK_INT(RT_NOCRT(__fpclassifyl)(RTStrNanLongDouble(NULL, true)), RT_NOCRT_FP_NAN);
863 CHECK_INT(RT_NOCRT(__fpclassifyl)(RTStrNanLongDouble("4sig", false)), RT_NOCRT_FP_NAN);
864}
865
866
867void testSignBit()
868{
869 RTTestSub(g_hTest, "__signbit[fl]");
870 CHECK_INT(RT_NOCRT(__signbit)( +0.0), 0);
871 CHECK_INT(RT_NOCRT(__signbit)( -0.0), 1);
872 CHECK_INT(RT_NOCRT(__signbit)( 1.0), 0);
873 CHECK_INT(RT_NOCRT(__signbit)( 2394.2340e200), 0);
874 CHECK_INT(RT_NOCRT(__signbit)(-2394.2340e200), 1);
875 CHECK_INT(RT_NOCRT(__signbit)(-2.1984e-310), 1); /* subnormal */
876 CHECK_INT(RT_NOCRT(__signbit)(-INFINITY), 1);
877 CHECK_INT(RT_NOCRT(__signbit)(+INFINITY), 0);
878 CHECK_INT(RT_NOCRT(__signbit)(RTStrNanDouble(NULL, true)), 0);
879 CHECK_INT(RT_NOCRT(__signbit)(RTStrNanDouble("4sig", false)), 1);
880
881 CHECK_INT(RT_NOCRT(__signbitf)( +0.0f), 0);
882 CHECK_INT(RT_NOCRT(__signbitf)( -0.0f), 1);
883 CHECK_INT(RT_NOCRT(__signbitf)( 1.0f), 0);
884 CHECK_INT(RT_NOCRT(__signbitf)( 2394.2340e20f), 0);
885 CHECK_INT(RT_NOCRT(__signbitf)(-2394.2340e20f), 1);
886 CHECK_INT(RT_NOCRT(__signbitf)(-2.1984e-40f), 1); /* subnormal */
887 CHECK_INT(RT_NOCRT(__signbitf)(-INFINITY), 1);
888 CHECK_INT(RT_NOCRT(__signbitf)(+INFINITY), 0);
889 CHECK_INT(RT_NOCRT(__signbitf)(RTStrNanFloat(NULL, true)), 0);
890 CHECK_INT(RT_NOCRT(__signbitf)(RTStrNanFloat("4sig", false)), 1);
891
892 CHECK_INT(RT_NOCRT(__signbitl)( +0.0L), 0);
893 CHECK_INT(RT_NOCRT(__signbitl)( -0.0L), 1);
894 CHECK_INT(RT_NOCRT(__signbitl)( 1.0L), 0);
895 CHECK_INT(RT_NOCRT(__signbitl)( 2394.2340e200L), 0);
896 CHECK_INT(RT_NOCRT(__signbitl)(-2394.2340e200L), 1);
897#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
898 CHECK_INT(RT_NOCRT(__signbitl)(-2.1984e-310L), 1); /* subnormal */
899#else
900 CHECK_INT(RT_NOCRT(__signbitl)(-2.1984e-4935L), 1); /* subnormal */
901#endif
902 CHECK_INT(RT_NOCRT(__signbitl)(-INFINITY), 1);
903 CHECK_INT(RT_NOCRT(__signbitl)(+INFINITY), 0);
904 CHECK_INT(RT_NOCRT(__signbitl)(RTStrNanLongDouble(NULL, true)), 0);
905 CHECK_INT(RT_NOCRT(__signbitl)(RTStrNanLongDouble("4sig", false)), 1);
906}
907
908
909void testCeil()
910{
911 RTTestSub(g_hTest, "ceil[f]");
912 CHECK_DBL(RT_NOCRT(ceil)( +0.0), +0.0);
913 CHECK_DBL(RT_NOCRT(ceil)( -0.0), -0.0);
914 CHECK_DBL(RT_NOCRT(ceil)( -42.0), -42.0);
915 CHECK_DBL(RT_NOCRT(ceil)( -42.5), -42.0);
916 CHECK_DBL(RT_NOCRT(ceil)( +42.5), +43.0);
917 CHECK_DBL(RT_NOCRT(ceil)(-42.25), -42.0);
918 CHECK_DBL(RT_NOCRT(ceil)(+42.25), +43.0);
919 CHECK_DBL_SAME(ceil,( -0.0));
920 CHECK_DBL_SAME(ceil,( +0.0));
921 CHECK_DBL_SAME(ceil,( +42.25));
922 CHECK_DBL_SAME(ceil,(+1234.60958634e+10));
923 CHECK_DBL_SAME(ceil,(-1234.60958634e+10));
924 CHECK_DBL_SAME(ceil,( -1234.499999e+10));
925 CHECK_DBL_SAME(ceil,( -1234.499999e-10));
926 CHECK_DBL_SAME(ceil,( -2.1984e-310)); /* subnormal */
927 CHECK_DBL_SAME(ceil,(-INFINITY));
928 CHECK_DBL_SAME(ceil,(+INFINITY));
929 CHECK_DBL_SAME(ceil,(RTStrNanDouble(NULL, true)));
930 CHECK_DBL_SAME(ceil,(RTStrNanDouble("s", false)));
931
932 CHECK_DBL(RT_NOCRT(ceilf)( +0.0f), +0.0f);
933 CHECK_DBL(RT_NOCRT(ceilf)( -0.0f), -0.0f);
934 CHECK_DBL(RT_NOCRT(ceilf)( -42.0f), -42.0f);
935 CHECK_DBL(RT_NOCRT(ceilf)( -42.5f), -42.0f);
936 CHECK_DBL(RT_NOCRT(ceilf)( +42.5f), +43.0f);
937 CHECK_DBL(RT_NOCRT(ceilf)(-42.25f), -42.0f);
938 CHECK_DBL(RT_NOCRT(ceilf)(+42.25f), +43.0f);
939 CHECK_DBL_SAME(ceilf,( -0.0f));
940 CHECK_DBL_SAME(ceilf,( +0.0f));
941 CHECK_DBL_SAME(ceilf,( +42.25f));
942 CHECK_DBL_SAME(ceilf,(+1234.60958634e+10f));
943 CHECK_DBL_SAME(ceilf,(-1234.60958634e+10f));
944 CHECK_DBL_SAME(ceilf,( -1234.499999e+10f));
945 CHECK_DBL_SAME(ceilf,( -1234.499999e-10f));
946 CHECK_DBL_SAME(ceilf,( -2.1984e-40f)); /* subnormal */
947 CHECK_DBL_SAME(ceilf,(-INFINITY));
948 CHECK_DBL_SAME(ceilf,(+INFINITY));
949 CHECK_DBL_SAME(ceilf,(RTStrNanFloat(NULL, true)));
950 CHECK_DBL_SAME(ceilf,(RTStrNanFloat("s", false)));
951}
952
953
954void testFloor()
955{
956 RTTestSub(g_hTest, "floor[f]");
957 CHECK_DBL(RT_NOCRT(floor)( +0.0), +0.0);
958 CHECK_DBL(RT_NOCRT(floor)( -0.0), -0.0);
959 CHECK_DBL(RT_NOCRT(floor)( -42.0), -42.0);
960 CHECK_DBL(RT_NOCRT(floor)( -42.5), -43.0);
961 CHECK_DBL(RT_NOCRT(floor)( +42.5), +42.0);
962 CHECK_DBL(RT_NOCRT(floor)(-42.25), -43.0);
963 CHECK_DBL(RT_NOCRT(floor)(+42.25), +42.0);
964 CHECK_DBL_SAME(floor,( -0.0));
965 CHECK_DBL_SAME(floor,( +0.0));
966 CHECK_DBL_SAME(floor,( +42.25));
967 CHECK_DBL_SAME(floor,(+1234.60958634e+10));
968 CHECK_DBL_SAME(floor,(-1234.60958634e+10));
969 CHECK_DBL_SAME(floor,( -1234.499999e+10));
970 CHECK_DBL_SAME(floor,( -1234.499999e-10));
971 CHECK_DBL_SAME(floor,( -2.1984e-310)); /* subnormal */
972 CHECK_DBL_SAME(floor,(-INFINITY));
973 CHECK_DBL_SAME(floor,(+INFINITY));
974 CHECK_DBL_SAME(floor,(RTStrNanDouble(NULL, true)));
975 CHECK_DBL_SAME(floor,(RTStrNanDouble("s", false)));
976
977 CHECK_DBL(RT_NOCRT(floorf)( +0.0f), +0.0f);
978 CHECK_DBL(RT_NOCRT(floorf)( -0.0f), -0.0f);
979 CHECK_DBL(RT_NOCRT(floorf)( -42.0f), -42.0f);
980 CHECK_DBL(RT_NOCRT(floorf)( -42.5f), -43.0f);
981 CHECK_DBL(RT_NOCRT(floorf)( +42.5f), +42.0f);
982 CHECK_DBL(RT_NOCRT(floorf)(-42.25f), -43.0f);
983 CHECK_DBL(RT_NOCRT(floorf)(+42.25f), +42.0f);
984 CHECK_DBL_SAME(floorf,( -0.0f));
985 CHECK_DBL_SAME(floorf,( +0.0f));
986 CHECK_DBL_SAME(floorf,( +42.25f));
987 CHECK_DBL_SAME(floorf,(+1234.60958634e+10f));
988 CHECK_DBL_SAME(floorf,(-1234.60958634e+10f));
989 CHECK_DBL_SAME(floorf,( -1234.499999e+10f));
990 CHECK_DBL_SAME(floorf,( -1234.499999e-10f));
991 CHECK_DBL_SAME(floorf,( -2.1984e-40f)); /* subnormal */
992 CHECK_DBL_SAME(floorf,(-INFINITY));
993 CHECK_DBL_SAME(floorf,(+INFINITY));
994 CHECK_DBL_SAME(floorf,(RTStrNanFloat(NULL, true)));
995 CHECK_DBL_SAME(floorf,(RTStrNanFloat("s", false)));
996}
997
998
999void testRound()
1000{
1001 RTTestSub(g_hTest, "round[f]");
1002 CHECK_DBL(RT_NOCRT(round)( +0.0), +0.0);
1003 CHECK_DBL(RT_NOCRT(round)( -0.0), -0.0);
1004 CHECK_DBL(RT_NOCRT(round)( -42.0), -42.0);
1005 CHECK_DBL(RT_NOCRT(round)( -42.5), -43.0);
1006 CHECK_DBL(RT_NOCRT(round)( +42.5), +43.0);
1007 CHECK_DBL(RT_NOCRT(round)(-42.25), -42.0);
1008 CHECK_DBL(RT_NOCRT(round)(+42.25), +42.0);
1009 CHECK_DBL_SAME(round,( -0.0));
1010 CHECK_DBL_SAME(round,( +0.0));
1011 CHECK_DBL_SAME(round,( +42.25));
1012 CHECK_DBL_SAME(round,(+1234.60958634e+10));
1013 CHECK_DBL_SAME(round,(-1234.60958634e+10));
1014 CHECK_DBL_SAME(round,( -1234.499999e+10));
1015 CHECK_DBL_SAME(round,( -1234.499999e-10));
1016 CHECK_DBL_SAME(round,( -2.1984e-310)); /* subnormal */
1017 CHECK_DBL_SAME(round,(-INFINITY));
1018 CHECK_DBL_SAME(round,(+INFINITY));
1019 CHECK_DBL_SAME(round,(RTStrNanDouble(NULL, true)));
1020 CHECK_DBL_SAME(round,(RTStrNanDouble("s", false)));
1021
1022 CHECK_DBL(RT_NOCRT(round)( +0.0f), +0.0f);
1023 CHECK_DBL(RT_NOCRT(round)( -0.0f), -0.0f);
1024 CHECK_DBL(RT_NOCRT(round)( -42.0f), -42.0f);
1025 CHECK_DBL(RT_NOCRT(round)( -42.5f), -43.0f);
1026 CHECK_DBL(RT_NOCRT(round)( +42.5f), +43.0f);
1027 CHECK_DBL(RT_NOCRT(round)(-42.25f), -42.0f);
1028 CHECK_DBL(RT_NOCRT(round)(+42.25f), +42.0f);
1029 CHECK_DBL_SAME(round,( -0.0f));
1030 CHECK_DBL_SAME(round,( +0.0f));
1031 CHECK_DBL_SAME(round,( +42.25f));
1032 CHECK_DBL_SAME(round,(+1234.60958634e+10f));
1033 CHECK_DBL_SAME(round,(-1234.60958634e+10f));
1034 CHECK_DBL_SAME(round,( -1234.499999e+10f));
1035 CHECK_DBL_SAME(round,( -1234.499999e-10f));
1036 CHECK_DBL_SAME(round,( -2.1984e-40f)); /* subnormal */
1037 CHECK_DBL_SAME(round,(-INFINITY));
1038 CHECK_DBL_SAME(round,(+INFINITY));
1039 CHECK_DBL_SAME(round,(RTStrNanFloat(NULL, true)));
1040 CHECK_DBL_SAME(round,(RTStrNanFloat("s", false)));
1041}
1042
1043
1044void testLRound()
1045{
1046 RTTestSub(g_hTest, "lround[f]");
1047 CHECK_LONG(RT_NOCRT(lround)( +0.0), 0);
1048 CHECK_LONG(RT_NOCRT(lround)( -0.0), 0);
1049 CHECK_LONG(RT_NOCRT(lround)( -42.0), -42);
1050 CHECK_LONG(RT_NOCRT(lround)( -42.5), -43);
1051 CHECK_LONG(RT_NOCRT(lround)( +42.5), +43);
1052 CHECK_LONG(RT_NOCRT(lround)( -42.25), -42);
1053 CHECK_LONG(RT_NOCRT(lround)( +42.25), +42);
1054 CHECK_LONG(RT_NOCRT(lround)(+1234.60958634e+20), LONG_MAX);
1055 CHECK_LONG(RT_NOCRT(lround)(-1234.60958634e+20), LONG_MIN);
1056 CHECK_LONG(RT_NOCRT(lround)( -1234.499999e+20), LONG_MIN);
1057 CHECK_LONG(RT_NOCRT(lround)( -1234.499999e-10), 0);
1058 CHECK_LONG(RT_NOCRT(lround)( -2.1984e-310), 0); /* subnormal */
1059 CHECK_LONG(RT_NOCRT(lround)(-INFINITY), LONG_MIN);
1060 CHECK_LONG(RT_NOCRT(lround)(+INFINITY), LONG_MAX);
1061 CHECK_LONG(RT_NOCRT(lround)(RTStrNanDouble(NULL, true)), LONG_MAX);
1062 CHECK_LONG(RT_NOCRT(lround)(RTStrNanDouble("s", false)), LONG_MAX);
1063 CHECK_LONG_SAME(lround,( -0.0));
1064 CHECK_LONG_SAME(lround,( +0.0));
1065 CHECK_LONG_SAME(lround,( +42.25));
1066 CHECK_LONG_SAME(lround,( +42.25e+6));
1067 CHECK_LONG_SAME(lround,( -42.25e+6));
1068 CHECK_LONG_SAME(lround,( -1234.499999e-10));
1069 CHECK_LONG_SAME(lround,( -2.1984e-310)); /* subnormal */
1070#if 0 /* unspecified, we test our expected behavior above */
1071 CHECK_LONG_SAME(lround,(+1234.60958634e+20));
1072 CHECK_LONG_SAME(lround,(-1234.60958634e+20));
1073 CHECK_LONG_SAME(lround,( -1234.499999e+20));
1074 CHECK_LONG_SAME(lround,(-INFINITY));
1075 CHECK_LONG_SAME(lround,(+INFINITY));
1076 CHECK_LONG_SAME(lround,(RTStrNanDouble(NULL, true)));
1077 CHECK_LONG_SAME(lround,(RTStrNanDouble("s", false)));
1078#endif
1079
1080 CHECK_LONG(RT_NOCRT(lroundf)( +0.0f), 0);
1081 CHECK_LONG(RT_NOCRT(lroundf)( -0.0f), 0);
1082 CHECK_LONG(RT_NOCRT(lroundf)( -42.0f), -42);
1083 CHECK_LONG(RT_NOCRT(lroundf)( -42.5f), -43);
1084 CHECK_LONG(RT_NOCRT(lroundf)( +42.5f), +43);
1085 CHECK_LONG(RT_NOCRT(lroundf)( -42.25f), -42);
1086 CHECK_LONG(RT_NOCRT(lroundf)( +42.25f), +42);
1087 CHECK_LONG(RT_NOCRT(lroundf)(+1234.60958634e+20f), LONG_MAX);
1088 CHECK_LONG(RT_NOCRT(lroundf)(-1234.60958634e+20f), LONG_MIN);
1089 CHECK_LONG(RT_NOCRT(lroundf)( -1234.499999e+20f), LONG_MIN);
1090 CHECK_LONG(RT_NOCRT(lroundf)( -1234.499999e-10f), 0);
1091 CHECK_LONG(RT_NOCRT(lroundf)( -2.1984e-40f), 0); /* subnormal */
1092 CHECK_LONG(RT_NOCRT(lroundf)(-INFINITY), LONG_MIN);
1093 CHECK_LONG(RT_NOCRT(lroundf)(+INFINITY), LONG_MAX);
1094 CHECK_LONG(RT_NOCRT(lroundf)(RTStrNanFloat(NULL, true)), LONG_MAX);
1095 CHECK_LONG(RT_NOCRT(lroundf)(RTStrNanFloat("s", false)), LONG_MAX);
1096 CHECK_LONG_SAME(lroundf,( -0.0f));
1097 CHECK_LONG_SAME(lroundf,( +0.0f));
1098 CHECK_LONG_SAME(lroundf,( +42.25f));
1099 CHECK_LONG_SAME(lroundf,( +42.25e+6f));
1100 CHECK_LONG_SAME(lroundf,( -42.25e+6f));
1101 CHECK_LONG_SAME(lroundf,( -1234.499999e-10f));
1102 CHECK_LONG_SAME(lroundf,( -2.1984e-40f)); /* subnormal */
1103#if 0 /* unspecified, we test our expected behavior above */
1104 CHECK_LONG_SAME(lroundf,(+1234.60958634e+20f));
1105 CHECK_LONG_SAME(lroundf,(-1234.60958634e+20f));
1106 CHECK_LONG_SAME(lroundf,( -1234.499999e+20f));
1107 CHECK_LONG_SAME(lroundf,(-INFINITY));
1108 CHECK_LONG_SAME(lroundf,(+INFINITY));
1109 CHECK_LONG_SAME(lroundf,(RTStrNanFloat(NULL, true)));
1110 CHECK_LONG_SAME(lroundf,(RTStrNanFloat("s", false)));
1111#endif
1112}
1113
1114
1115void testLLRound()
1116{
1117 RTTestSub(g_hTest, "llround[f]");
1118 CHECK_LLONG(RT_NOCRT(llround)( +0.0), 0);
1119 CHECK_LLONG(RT_NOCRT(llround)( -0.0), 0);
1120 CHECK_LLONG(RT_NOCRT(llround)( -42.0), -42);
1121 CHECK_LLONG(RT_NOCRT(llround)( -42.5), -43);
1122 CHECK_LLONG(RT_NOCRT(llround)( +42.5), +43);
1123 CHECK_LLONG(RT_NOCRT(llround)(-42.25), -42);
1124 CHECK_LLONG(RT_NOCRT(llround)(+42.25), +42);
1125 CHECK_LLONG(RT_NOCRT(llround)(+42.25e4), +422500);
1126 CHECK_LLONG(RT_NOCRT(llround)(+42.25e12), +42250000000000LL);
1127 CHECK_LLONG(RT_NOCRT(llround)(+1234.60958634e+20), LLONG_MAX);
1128 CHECK_LLONG(RT_NOCRT(llround)(-1234.60958634e+20), LLONG_MIN);
1129 CHECK_LLONG(RT_NOCRT(llround)( -1234.499999e+20), LLONG_MIN);
1130 CHECK_LLONG(RT_NOCRT(llround)( -1234.499999e-10), 0);
1131 CHECK_LLONG(RT_NOCRT(llround)( -2.1984e-310), 0); /* subnormal */
1132 CHECK_LLONG(RT_NOCRT(llround)(-INFINITY), LLONG_MIN);
1133 CHECK_LLONG(RT_NOCRT(llround)(+INFINITY), LLONG_MAX);
1134 CHECK_LLONG(RT_NOCRT(llround)(RTStrNanDouble(NULL, true)), LLONG_MAX);
1135 CHECK_LLONG(RT_NOCRT(llround)(RTStrNanDouble("s", false)), LLONG_MAX);
1136 CHECK_LLONG_SAME(llround,( -0.0));
1137 CHECK_LLONG_SAME(llround,( +0.0));
1138 CHECK_LLONG_SAME(llround,( +42.25));
1139 CHECK_LLONG_SAME(llround,( +42.25e+6));
1140 CHECK_LLONG_SAME(llround,( -42.25e+6));
1141 CHECK_LLONG_SAME(llround,( -42.25e+12));
1142 CHECK_LLONG_SAME(llround,( +42.265785e+13));
1143 CHECK_LLONG_SAME(llround,( -1234.499999e-10));
1144 CHECK_LLONG_SAME(llround,( -2.1984e-310)); /* subnormal */
1145#if 0 /* unspecified, we test our expected behavior above */
1146 CHECK_LLONG_SAME(llround,(+1234.60958634e+20));
1147 CHECK_LLONG_SAME(llround,(-1234.60958634e+20));
1148 CHECK_LLONG_SAME(llround,( -1234.499999e+20));
1149 CHECK_LLONG_SAME(llround,(-INFINITY));
1150 CHECK_LLONG_SAME(llround,(+INFINITY));
1151 CHECK_LLONG_SAME(llround,(RTStrNanDouble(NULL, true)));
1152 CHECK_LLONG_SAME(llround,(RTStrNanDouble("s", false)));
1153#endif
1154
1155 CHECK_LLONG(RT_NOCRT(llroundf)( +0.0f), 0);
1156 CHECK_LLONG(RT_NOCRT(llroundf)( -0.0f), 0);
1157 CHECK_LLONG(RT_NOCRT(llroundf)( -42.0f), -42);
1158 CHECK_LLONG(RT_NOCRT(llroundf)( -42.5f), -43);
1159 CHECK_LLONG(RT_NOCRT(llroundf)( +42.5f), +43);
1160 CHECK_LLONG(RT_NOCRT(llroundf)(-42.25f), -42);
1161 CHECK_LLONG(RT_NOCRT(llroundf)(+42.25f), +42);
1162 CHECK_LLONG(RT_NOCRT(llroundf)(+42.25e4f), +422500);
1163 CHECK_LLONG(RT_NOCRT(llroundf)(+42.24e10f), +422400000000LL);
1164 CHECK_LLONG(RT_NOCRT(llroundf)(+1234.60958634e+20f), LLONG_MAX);
1165 CHECK_LLONG(RT_NOCRT(llroundf)(-1234.60958634e+20f), LLONG_MIN);
1166 CHECK_LLONG(RT_NOCRT(llroundf)( -1234.499999e+20f), LLONG_MIN);
1167 CHECK_LLONG(RT_NOCRT(llroundf)( -1234.499999e-10f), 0);
1168 CHECK_LLONG(RT_NOCRT(llroundf)( -2.1984e-40f), 0); /* subnormal */
1169 CHECK_LLONG(RT_NOCRT(llroundf)(-INFINITY), LLONG_MIN);
1170 CHECK_LLONG(RT_NOCRT(llroundf)(+INFINITY), LLONG_MAX);
1171 CHECK_LLONG(RT_NOCRT(llroundf)(RTStrNanFloat(NULL, true)), LLONG_MAX);
1172 CHECK_LLONG(RT_NOCRT(llroundf)(RTStrNanFloat("s", false)), LLONG_MAX);
1173 CHECK_LLONG_SAME(llroundf,( -0.0f));
1174 CHECK_LLONG_SAME(llroundf,( +0.0f));
1175 CHECK_LLONG_SAME(llroundf,( +42.25f));
1176 CHECK_LLONG_SAME(llroundf,( +42.25e+6f));
1177 CHECK_LLONG_SAME(llroundf,( -42.25e+6f));
1178 CHECK_LLONG_SAME(llroundf,( -42.25e+12f));
1179 CHECK_LLONG_SAME(llroundf,( +42.265785e+13f));
1180 CHECK_LLONG_SAME(llroundf,( -1234.499999e-10f));
1181 CHECK_LLONG_SAME(llroundf,( -2.1984e-40f)); /* subnormal */
1182#if 0 /* unspecified, we test our expected behavior above */
1183 CHECK_LLONG_SAME(llroundf,(+1234.60958634e+20f));
1184 CHECK_LLONG_SAME(llroundf,(-1234.60958634e+20f));
1185 CHECK_LLONG_SAME(llroundf,( -1234.499999e+20f));
1186 CHECK_LLONG_SAME(llroundf,(-INFINITY));
1187 CHECK_LLONG_SAME(llroundf,(+INFINITY));
1188 CHECK_LLONG_SAME(llroundf,(RTStrNanFloat(NULL, true)));
1189 CHECK_LLONG_SAME(llroundf,(RTStrNanFloat("s", false)));
1190#endif
1191
1192#if 0
1193 CHECK_LLONG(RT_NOCRT(llroundl)( +0.0L), 0);
1194 CHECK_LLONG(RT_NOCRT(llroundl)( -0.0L), 0);
1195 CHECK_LLONG(RT_NOCRT(llroundl)( -42.0L), -42);
1196 CHECK_LLONG(RT_NOCRT(llroundl)( -42.5L), -43);
1197 CHECK_LLONG(RT_NOCRT(llroundl)( +42.5L), +43);
1198 CHECK_LLONG(RT_NOCRT(llroundl)(-42.25L), -42);
1199 CHECK_LLONG(RT_NOCRT(llroundl)(+42.25L), +42);
1200 CHECK_LLONG(RT_NOCRT(llroundl)(+42.25e4L), +422500);
1201 CHECK_LLONG(RT_NOCRT(llroundl)(+42.24e12L), +42240000000000LL);
1202 CHECK_LLONG(RT_NOCRT(llroundl)(+1234.60958634e+20L), LLONG_MAX);
1203 CHECK_LLONG(RT_NOCRT(llroundl)(-1234.60958634e+20L), LLONG_MIN);
1204 CHECK_LLONG(RT_NOCRT(llroundl)( -1234.499999e+20L), LLONG_MIN);
1205 CHECK_LLONG(RT_NOCRT(llroundl)( -1234.499999e-10L), 0);
1206#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
1207 CHECK_LLONG(RT_NOCRT(llroundl)( -2.1984e-310L), 0); /* subnormal */
1208#else
1209 CHECK_LLONG(RT_NOCRT(llroundl)( -2.1984e-4935L), 0); /* subnormal */
1210#endif
1211 CHECK_LLONG(RT_NOCRT(llroundl)(-INFINITY), LLONG_MIN);
1212 CHECK_LLONG(RT_NOCRT(llroundl)(+INFINITY), LLONG_MAX);
1213 CHECK_LLONG(RT_NOCRT(llroundl)(RTStrNanLongDouble(NULL, true)), LLONG_MAX);
1214 CHECK_LLONG(RT_NOCRT(llroundl)(RTStrNanLongDouble("s", false)), LLONG_MAX);
1215 CHECK_LLONG_SAME(llroundl,( -0.0));
1216 CHECK_LLONG_SAME(llroundl,( +0.0));
1217 CHECK_LLONG_SAME(llroundl,( +42.25));
1218 CHECK_LLONG_SAME(llroundl,( +42.25e+6));
1219 CHECK_LLONG_SAME(llroundl,( -42.25e+6));
1220 CHECK_LLONG_SAME(llroundl,( -42.25e+12));
1221 CHECK_LLONG_SAME(llroundl,( +42.265785e+13));
1222 CHECK_LLONG_SAME(llroundl,( -1234.499999e-10L));
1223# ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
1224 CHECK_LLONG_SAME(llroundl,( -2.1984e-310L)); /* subnormal */
1225# else
1226 CHECK_LLONG_SAME(llroundl,( -2.1984e-4935L)); /* subnormal */
1227# endif
1228#if 0 /* unspecified, we test our expected behavior above */
1229 CHECK_LLONG_SAME(llroundl,(+1234.60958634e+20L));
1230 CHECK_LLONG_SAME(llroundl,(-1234.60958634e+20L));
1231 CHECK_LLONG_SAME(llroundl,( -1234.499999e+20L));
1232 CHECK_LLONG_SAME(llroundl,(-INFINITY));
1233 CHECK_LLONG_SAME(llroundl,(+INFINITY));
1234 CHECK_LLONG_SAME(llroundl,(RTStrNanLongDouble(NULL, true)));
1235 CHECK_LLONG_SAME(llroundl,(RTStrNanLongDouble("s", false)));
1236#endif
1237#endif
1238}
1239
1240
1241int main()
1242{
1243 RTEXITCODE rcExit = RTTestInitAndCreate("tstRTNoCrt-2", &g_hTest);
1244 if (rcExit != RTEXITCODE_SUCCESS)
1245 return rcExit;
1246
1247 /* stdlib.h (integer) */
1248 testAbs();
1249
1250 /* math.h */
1251 testCopySign();
1252 testExp2();
1253 testFma();
1254 testFmax();
1255 testFmin();
1256 testIsInf();
1257 testIsNan();
1258 testIsFinite();
1259 testIsNormal();
1260 testFpClassify();
1261 testSignBit();
1262 testCeil();
1263 testFloor();
1264 testRound();
1265 testLRound();
1266 testLLRound();
1267
1268#if 0
1269 ../common/math/atan.asm \
1270 ../common/math/atan2.asm \
1271 ../common/math/atan2f.asm \
1272 ../common/math/atanf.asm \
1273 ../common/math/cos.asm \
1274 ../common/math/cosf.asm \
1275 ../common/math/cosl.asm \
1276 ../common/math/exp2.asm \
1277 ../common/math/exp2f.asm \
1278 ../common/math/fabs.asm \
1279 ../common/math/fabsf.asm \
1280 ../common/math/fma-asm.asm \
1281 ../common/math/fmaf-asm.asm \
1282 ../common/math/ldexp.asm \
1283 ../common/math/ldexpf.asm \
1284 ../common/math/llrint.asm \
1285 ../common/math/llrintf.asm \
1286 ../common/math/log.asm \
1287 ../common/math/logf.asm \
1288 ../common/math/lrint.asm \
1289 ../common/math/lrintf.asm \
1290 ../common/math/remainder.asm \
1291 ../common/math/remainderf.asm \
1292 ../common/math/rint.asm \
1293 ../common/math/rintf.asm \
1294 ../common/math/sin.asm \
1295 ../common/math/sinf.asm \
1296 ../common/math/sqrt.asm \
1297 ../common/math/sqrtf.asm \
1298 ../common/math/tan.asm \
1299 ../common/math/tanf.asm \
1300 ../common/math/trunc.asm \
1301 ../common/math/truncf.asm
1302#endif
1303
1304
1305 return RTTestSummaryAndDestroy(g_hTest);
1306}
1307
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