VirtualBox

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

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

IPRT/nocrt: Implemented x86 and amd64 fenv.h to assist with the testing. More tests. bugref:10261

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 75.9 KB
Line 
1/* $Id: tstRTNoCrt-2.cpp 96205 2022-08-14 23:40:55Z 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#elif defined(RT_COMPILER_WITH_128BIT_LONG_DOUBLE)
157# error todo
158#else
159# define CHECK_LDBL(a_Expr, a_lrdExpect) do { \
160 RTFLOAT64U uRet; \
161 uRet.lrd = (a_Expr); \
162 RTFLOAT64U uExpect; \
163 uExpect.lrd = a_lrdExpect; \
164 if (!RTFLOAT64U_ARE_IDENTICAL(&uRet, &uExpect)) \
165 { \
166 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
167 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
168 RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
169 __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_lrdExpect); \
170 } \
171 } while (0)
172
173#define CHECK_LDBL_SAME(a_Fn, a_Args) do { \
174 RTFLOAT64U uNoCrtRet, uCrtRet; \
175 uNoCrtRet.lrd = RT_NOCRT(a_Fn) a_Args; \
176 uCrtRet.lrd = a_Fn a_Args; \
177 if (!RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
178 { \
179 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
180 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
181 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
182 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
183 } \
184 } while (0)
185
186#define CHECK_LDBL_APPROX_SAME(a_Fn, a_Args) do { \
187 RTFLOAT64U uNoCrtRet, uCrtRet; \
188 uNoCrtRet.lrd = RT_NOCRT(a_Fn) a_Args; \
189 uCrtRet.lrd = a_Fn a_Args; \
190 if ( !RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
191 && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
192 || RTFLOAT64U_IS_NAN(&uNoCrtRet) \
193 || RTFLOAT64U_IS_NAN(&uCrtRet) ) ) \
194 { \
195 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
196 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
197 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
198 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
199 } \
200 } while (0)
201#endif
202
203
204/*
205 * Macros checking d o u b l e returns.
206 */
207#define CHECK_DBL(a_Expr, a_rdExpect) do { \
208 RTFLOAT64U uRet; \
209 uRet.r = (a_Expr); \
210 RTFLOAT64U uExpect; \
211 uExpect.r = a_rdExpect; \
212 if (!RTFLOAT64U_ARE_IDENTICAL(&uRet, &uExpect)) \
213 { \
214 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
215 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
216 RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
217 __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_rdExpect); \
218 } \
219 } while (0)
220
221#define CHECK_DBL_SAME(a_Fn, a_Args) do { \
222 RTFLOAT64U uNoCrtRet, uCrtRet; \
223 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
224 uCrtRet.r = a_Fn a_Args; \
225 if (!RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &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
234#define CHECK_DBL_APPROX_SAME(a_Fn, a_Args) do { \
235 RTFLOAT64U uNoCrtRet, uCrtRet; \
236 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
237 uCrtRet.r = a_Fn a_Args; \
238 if ( !RTFLOAT64U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
239 && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
240 || RTFLOAT64U_IS_NAN(&uNoCrtRet) \
241 || RTFLOAT64U_IS_NAN(&uCrtRet) ) ) \
242 { \
243 RTStrFormatR64(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
244 RTStrFormatR64(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
245 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
246 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
247 } \
248 } while (0)
249
250/*
251 * Macros checking f l o a t returns.
252 */
253#define CHECK_FLT(a_Expr, a_rExpect) do { \
254 RTFLOAT32U uRet; \
255 uRet.r = (a_Expr); \
256 RTFLOAT32U uExpect; \
257 uExpect.r = a_rExpect; \
258 if (!RTFLOAT32U_ARE_IDENTICAL(&uRet, &uExpect)) \
259 { \
260 RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uRet, 0, 0, RTSTR_F_SPECIAL); \
261 RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uExpect, 0, 0, RTSTR_F_SPECIAL); \
262 RTTestFailed(g_hTest, "line %u: %s -> %s, expected %s (%s)", \
263 __LINE__, #a_Expr, g_szFloat[0], g_szFloat[1], #a_rExpect); \
264 } \
265 } while (0)
266
267#define CHECK_FLT_SAME(a_Fn, a_Args) do { \
268 RTFLOAT32U uNoCrtRet, uCrtRet; \
269 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
270 uCrtRet.r = a_Fn a_Args; \
271 if (!RTFLOAT32U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet)) \
272 { \
273 RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
274 RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
275 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
276 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
277 } \
278 } while (0)
279
280#define CHECK_FLT_APPROX_SAME(a_Fn, a_Args) do { \
281 RTFLOAT32U uNoCrtRet, uCrtRet; \
282 uNoCrtRet.r = RT_NOCRT(a_Fn) a_Args; \
283 uCrtRet.r = a_Fn a_Args; \
284 if ( !RTFLOAT32U_ARE_IDENTICAL(&uNoCrtRet, &uCrtRet) \
285 && ( (uNoCrtRet.u >= uCrtRet.u ? uNoCrtRet.u - uCrtRet.u : uCrtRet.u - uNoCrtRet.u) > 1 /* off by one is okay */ \
286 || RTFLOAT32U_IS_NAN(&uNoCrtRet) \
287 || RTFLOAT32U_IS_NAN(&uCrtRet) ) ) \
288 { \
289 RTStrFormatR32(g_szFloat[0], sizeof(g_szFloat[0]), &uNoCrtRet, 0, 0, RTSTR_F_SPECIAL); \
290 RTStrFormatR32(g_szFloat[1], sizeof(g_szFloat[0]), &uCrtRet, 0, 0, RTSTR_F_SPECIAL); \
291 RTTestFailed(g_hTest, "line %u: %s%s: noCRT => %s; CRT => %s", \
292 __LINE__, #a_Fn, #a_Args, g_szFloat[0], g_szFloat[1]); \
293 } \
294 } while (0)
295
296
297/*********************************************************************************************************************************
298* Global Variables *
299*********************************************************************************************************************************/
300RTTEST g_hTest;
301char g_szFloat[2][128];
302
303
304#ifdef _MSC_VER
305# pragma fenv_access(on)
306#endif
307
308
309void testAbs()
310{
311 RTTestSub(g_hTest, "abs,labs,llabs");
312 CHECK_INT(RT_NOCRT(abs)(1), 1);
313 CHECK_INT(RT_NOCRT(abs)(-1), 1);
314 CHECK_INT(RT_NOCRT(abs)(9685), 9685);
315 CHECK_INT(RT_NOCRT(abs)(-9685), 9685);
316 CHECK_INT(RT_NOCRT(abs)(589685), 589685);
317 CHECK_INT(RT_NOCRT(abs)(-589685), 589685);
318 CHECK_INT(RT_NOCRT(abs)(INT_MAX), INT_MAX);
319 CHECK_INT(RT_NOCRT(abs)(INT_MIN + 1), INT_MAX);
320 CHECK_INT(RT_NOCRT(abs)(INT_MIN), INT_MIN); /* oddity */
321 CHECK_INT_SAME(abs,(INT_MIN));
322 CHECK_INT_SAME(abs,(INT_MAX));
323
324 CHECK_LONG(RT_NOCRT(labs)(1), 1);
325 CHECK_LONG(RT_NOCRT(labs)(-1), 1);
326 CHECK_LONG(RT_NOCRT(labs)(9685), 9685);
327 CHECK_LONG(RT_NOCRT(labs)(-9685), 9685);
328 CHECK_LONG(RT_NOCRT(labs)(589685), 589685);
329 CHECK_LONG(RT_NOCRT(labs)(-589685), 589685);
330 CHECK_LONG(RT_NOCRT(labs)(LONG_MAX), LONG_MAX);
331 CHECK_LONG(RT_NOCRT(labs)(LONG_MIN + 1), LONG_MAX);
332 CHECK_LONG(RT_NOCRT(labs)(LONG_MIN), LONG_MIN); /* oddity */
333 CHECK_LONG_SAME(labs,(LONG_MIN));
334 CHECK_LONG_SAME(labs,(LONG_MAX));
335
336 CHECK_LONG(RT_NOCRT(llabs)(1), 1);
337 CHECK_LONG(RT_NOCRT(llabs)(-1), 1);
338 CHECK_LONG(RT_NOCRT(llabs)(9685), 9685);
339 CHECK_LONG(RT_NOCRT(llabs)(-9685), 9685);
340 CHECK_LONG(RT_NOCRT(llabs)(589685), 589685);
341 CHECK_LONG(RT_NOCRT(llabs)(-589685), 589685);
342 CHECK_LONG(RT_NOCRT(llabs)(LONG_MAX), LONG_MAX);
343 CHECK_LONG(RT_NOCRT(llabs)(LONG_MIN + 1), LONG_MAX);
344 CHECK_LONG(RT_NOCRT(llabs)(LONG_MIN), LONG_MIN); /* oddity */
345 CHECK_LONG_SAME(llabs,(LONG_MIN));
346 CHECK_LONG_SAME(llabs,(LONG_MAX));
347}
348
349
350void testCopySign()
351{
352 RTTestSub(g_hTest, "copysign[fl]");
353
354 CHECK_DBL(RT_NOCRT(copysign)(1.0, 2.0), 1.0);
355 CHECK_DBL(RT_NOCRT(copysign)(-1.0, 2.0), 1.0);
356 CHECK_DBL(RT_NOCRT(copysign)(-1.0, -2.0), -1.0);
357 CHECK_DBL(RT_NOCRT(copysign)(1.0, -2.0), -1.0);
358 CHECK_DBL(RT_NOCRT(copysign)(42.24, -INFINITY), -42.24);
359 CHECK_DBL(RT_NOCRT(copysign)(-42.24, +INFINITY), +42.24);
360 CHECK_DBL(RT_NOCRT(copysign)(-999888777.666, RTStrNanDouble(NULL, true)), +999888777.666);
361 CHECK_DBL(RT_NOCRT(copysign)(-999888777.666, RTStrNanDouble("sig", true)), +999888777.666);
362 CHECK_DBL(RT_NOCRT(copysign)(+999888777.666, RTStrNanDouble(NULL, false)), -999888777.666);
363 CHECK_DBL_SAME(copysign,(1.0, 2.0));
364 CHECK_DBL_SAME(copysign,(-1.0, 2.0));
365 CHECK_DBL_SAME(copysign,(-1.0, -2.0));
366 CHECK_DBL_SAME(copysign,(1.0, -2.0));
367 CHECK_DBL_SAME(copysign,(42.24, -INFINITY));
368 CHECK_DBL_SAME(copysign,(-42.24, +INFINITY));
369 CHECK_DBL_SAME(copysign,(-999888777.666, RTStrNanDouble(NULL, true)));
370 CHECK_DBL_SAME(copysign,(+999888777.666, RTStrNanDouble(NULL, false)));
371 CHECK_DBL_SAME(copysign,(+999888777.666, RTStrNanDouble("sig", false)));
372
373 CHECK_FLT(RT_NOCRT(copysignf)(1.0f, 2.0f), 1.0f);
374 CHECK_FLT(RT_NOCRT(copysignf)(-1.0f, 2.0f), 1.0f);
375 CHECK_FLT(RT_NOCRT(copysignf)(-1.0f, -2.0f), -1.0f);
376 CHECK_FLT(RT_NOCRT(copysignf)(1.0f, -2.0f), -1.0f);
377 CHECK_FLT(RT_NOCRT(copysignf)(42.24f, -INFINITY), -42.24f);
378 CHECK_FLT(RT_NOCRT(copysignf)(-42.24f, +INFINITY), +42.24f);
379 CHECK_FLT(RT_NOCRT(copysignf)(-999888777.666f, RTStrNanFloat(NULL, true)), +999888777.666f);
380 CHECK_FLT(RT_NOCRT(copysignf)(+999888777.666f, RTStrNanFloat(NULL, false)), -999888777.666f);
381 CHECK_FLT_SAME(copysignf,(1.0f, 2.0f));
382 CHECK_FLT_SAME(copysignf,(-3.0f, 2.0f));
383 CHECK_FLT_SAME(copysignf,(-5.0e3f, -2.0f));
384 CHECK_FLT_SAME(copysignf,(6.0e-3f, -2.0f));
385 CHECK_FLT_SAME(copysignf,(434.24f, -INFINITY));
386 CHECK_FLT_SAME(copysignf,(-42.24f, +INFINITY));
387 CHECK_FLT_SAME(copysignf,(-39480.6e+33f, RTStrNanFloat(NULL, true)));
388 CHECK_FLT_SAME(copysignf,(+39480.6e-32f, RTStrNanFloat(NULL, false)));
389
390 CHECK_LDBL(RT_NOCRT(copysignl)(1.0L, 2.0L), 1.0L);
391 CHECK_LDBL(RT_NOCRT(copysignl)(-1.0L, 2.0L), 1.0L);
392 CHECK_LDBL(RT_NOCRT(copysignl)(-1.0L, -2.0L), -1.0L);
393 CHECK_LDBL(RT_NOCRT(copysignl)(1.0L, -2.0L), -1.0L);
394 CHECK_LDBL(RT_NOCRT(copysignl)(42.24L, -INFINITY), -42.24L);
395 CHECK_LDBL(RT_NOCRT(copysignl)(-42.24L, +INFINITY), +42.24L);
396 CHECK_LDBL(RT_NOCRT(copysignl)(-999888777.666L, RTStrNanLongDouble(NULL, true)), +999888777.666L);
397 CHECK_LDBL(RT_NOCRT(copysignl)(+999888777.666L, RTStrNanLongDouble("2343f_sig", false)), -999888777.666L);
398 CHECK_LDBL_SAME(copysignl,(1.0L, 2.0L));
399 CHECK_LDBL_SAME(copysignl,(-3.0L, 2.0L));
400 CHECK_LDBL_SAME(copysignl,(-5.0e3L, -2.0L));
401 CHECK_LDBL_SAME(copysignl,(6.0e-3L, -2.0L));
402 CHECK_LDBL_SAME(copysignl,(434.24L, -INFINITY));
403 CHECK_LDBL_SAME(copysignl,(-42.24L, +INFINITY));
404 CHECK_LDBL_SAME(copysignl,(-39480.6e+33L, RTStrNanLongDouble("8888_s", true)));
405 CHECK_LDBL_SAME(copysignl,(+39480.6e-32L, RTStrNanLongDouble(NULL, false)));
406}
407
408
409void testExp2()
410{
411 RTTestSub(g_hTest, "exp2[f]");
412
413 CHECK_DBL(RT_NOCRT(exp2)(1.0), 2.0);
414 CHECK_DBL(RT_NOCRT(exp2)(2.0), 4.0);
415 CHECK_DBL(RT_NOCRT(exp2)(32.0), 4294967296.0);
416 CHECK_DBL(RT_NOCRT(exp2)(-1.0), 0.5);
417 CHECK_DBL(RT_NOCRT(exp2)(-3.0), 0.125);
418 CHECK_DBL_SAME(exp2, (0.0));
419 CHECK_DBL_SAME(exp2, (+INFINITY));
420 CHECK_DBL_SAME(exp2, (-INFINITY));
421 CHECK_DBL_SAME(exp2, (nan("1")));
422 CHECK_DBL_SAME(exp2, (RTStrNanDouble("ab305f", true)));
423 CHECK_DBL_SAME(exp2, (RTStrNanDouble("fffffffff_signaling", true)));
424 CHECK_DBL_SAME(exp2, (RTStrNanDouble("7777777777778_sig", false)));
425 CHECK_DBL_SAME(exp2, (1.0));
426 CHECK_DBL_SAME(exp2, (2.0));
427 CHECK_DBL_SAME(exp2, (-1.0));
428 CHECK_DBL_APPROX_SAME(exp2, (+0.5));
429 CHECK_DBL_APPROX_SAME(exp2, (-0.5));
430 CHECK_DBL_APPROX_SAME(exp2, (+1.5));
431 CHECK_DBL_APPROX_SAME(exp2, (-1.5));
432 CHECK_DBL_APPROX_SAME(exp2, (+3.25));
433 CHECK_DBL_APPROX_SAME(exp2, (99.2559430));
434 CHECK_DBL_APPROX_SAME(exp2, (-99.2559430));
435 CHECK_DBL_APPROX_SAME(exp2, (+305.2559430));
436 CHECK_DBL_APPROX_SAME(exp2, (-305.2559430));
437 CHECK_DBL_APPROX_SAME(exp2, (+309.99884));
438 CHECK_DBL_APPROX_SAME(exp2, (-309.111048));
439 CHECK_DBL_APPROX_SAME(exp2, (+999.864597634));
440 CHECK_DBL_APPROX_SAME(exp2, (-999.098234837));
441
442
443 CHECK_FLT(RT_NOCRT(exp2f)(1.0f), 2.0f);
444 CHECK_FLT(RT_NOCRT(exp2f)(2.0f), 4.0f);
445 CHECK_FLT(RT_NOCRT(exp2f)(32.0f), 4294967296.0f);
446 CHECK_FLT(RT_NOCRT(exp2f)(-1.0f), 0.5f);
447 CHECK_FLT(RT_NOCRT(exp2f)(-3.0f), 0.125f);
448 CHECK_FLT_SAME(exp2f, (0.0f));
449 CHECK_FLT_SAME(exp2f, (+INFINITY));
450 CHECK_FLT_SAME(exp2f, (-INFINITY));
451 CHECK_FLT_SAME(exp2f, (nan("1")));
452 CHECK_FLT_SAME(exp2f, (RTStrNanFloat("ab305f", true)));
453 CHECK_FLT_SAME(exp2f, (RTStrNanFloat("3fffff_signaling", true)));
454 CHECK_FLT_SAME(exp2f, (RTStrNanFloat("79778_sig", false)));
455 CHECK_FLT_SAME(exp2f, (1.0f));
456 CHECK_FLT_SAME(exp2f, (2.0f));
457 CHECK_FLT_SAME(exp2f, (-1.0f));
458 CHECK_FLT_APPROX_SAME(exp2f, (+0.5f));
459 CHECK_FLT_APPROX_SAME(exp2f, (-0.5f));
460 CHECK_FLT_APPROX_SAME(exp2f, (+1.5f));
461 CHECK_FLT_APPROX_SAME(exp2f, (-1.5f));
462 CHECK_FLT_APPROX_SAME(exp2f, (+3.25f));
463 CHECK_FLT_APPROX_SAME(exp2f, (99.25594f));
464 CHECK_FLT_APPROX_SAME(exp2f, (-99.25594f));
465 CHECK_FLT_APPROX_SAME(exp2f, (+305.25594f));
466 CHECK_FLT_APPROX_SAME(exp2f, (-305.25594f));
467 CHECK_FLT_APPROX_SAME(exp2f, (+309.99884f));
468 CHECK_FLT_APPROX_SAME(exp2f, (-309.111048f));
469 CHECK_FLT_APPROX_SAME(exp2f, (+999.86459f));
470 CHECK_FLT_APPROX_SAME(exp2f, (-999.09823f));
471}
472
473
474void testFma()
475{
476 RTTestSub(g_hTest, "fma[f]");
477
478 CHECK_DBL(RT_NOCRT(fma)(1.0, 1.0, 1.0), 2.0);
479 CHECK_DBL(RT_NOCRT(fma)(4.0, 2.0, 1.0), 9.0);
480 CHECK_DBL(RT_NOCRT(fma)(4.0, 2.0, -1.0), 7.0);
481 CHECK_DBL_SAME(fma, (0.0, 0.0, 0.0));
482 CHECK_DBL_SAME(fma, (999999.0, 33334.0, 29345.0));
483 CHECK_DBL_SAME(fma, (39560.32334, 9605.5546, -59079.345069));
484 CHECK_DBL_SAME(fma, (39560.32334, -59079.345069, 9605.5546));
485 CHECK_DBL_SAME(fma, (-59079.345069, 39560.32334, 9605.5546));
486 CHECK_DBL_SAME(fma, (+INFINITY, +INFINITY, -INFINITY));
487 CHECK_DBL_SAME(fma, (4.0, +INFINITY, 2.0));
488 CHECK_DBL_SAME(fma, (4.0, 4.0, +INFINITY));
489 CHECK_DBL_SAME(fma, (-INFINITY, 4.0, 4.0));
490 CHECK_DBL_SAME(fma, (2.34960584706e100, 7.6050698459e-13, 9.99996777e77));
491
492 CHECK_FLT(RT_NOCRT(fmaf)(1.0f, 1.0f, 1.0), 2.0);
493 CHECK_FLT(RT_NOCRT(fmaf)(4.0f, 2.0f, 1.0), 9.0);
494 CHECK_FLT(RT_NOCRT(fmaf)(4.0f, 2.0f, -1.0), 7.0);
495 CHECK_FLT_SAME(fmaf, (0.0f, 0.0f, 0.0f));
496 CHECK_FLT_SAME(fmaf, (999999.0f, 33334.0f, 29345.0f));
497 CHECK_FLT_SAME(fmaf, (39560.32334f, 9605.5546f, -59079.345069f));
498 CHECK_FLT_SAME(fmaf, (39560.32334f, -59079.345069f, 9605.5546f));
499 CHECK_FLT_SAME(fmaf, (-59079.345069f, 39560.32334f, 9605.5546f));
500 CHECK_FLT_SAME(fmaf, (+INFINITY, +INFINITY, -INFINITY));
501 CHECK_FLT_SAME(fmaf, (4.0f, +INFINITY, 2.0f));
502 CHECK_FLT_SAME(fmaf, (4.0f, 4.0f, +INFINITY));
503 CHECK_FLT_SAME(fmaf, (-INFINITY, 4.0f, 4.0f));
504 CHECK_FLT_SAME(fmaf, (2.34960584706e22f, 7.6050698459e-13f, 9.99996777e27f));
505}
506
507
508void testFmax()
509{
510 RTTestSub(g_hTest, "fmax[fl]");
511
512 CHECK_DBL(RT_NOCRT(fmax)( 1.0, 1.0), 1.0);
513 CHECK_DBL(RT_NOCRT(fmax)( 4.0, 2.0), 4.0);
514 CHECK_DBL(RT_NOCRT(fmax)( 2.0, 4.0), 4.0);
515 CHECK_DBL(RT_NOCRT(fmax)(-2.0, -4.0), -2.0);
516 CHECK_DBL(RT_NOCRT(fmax)(-2.0, -4.0e-10), -4.0e-10);
517 CHECK_DBL(RT_NOCRT(fmax)(+INFINITY, +INFINITY), +INFINITY);
518 CHECK_DBL(RT_NOCRT(fmax)(-INFINITY, -INFINITY), -INFINITY);
519 CHECK_DBL(RT_NOCRT(fmax)(+INFINITY, -INFINITY), +INFINITY);
520 CHECK_DBL(RT_NOCRT(fmax)(-INFINITY, +INFINITY), +INFINITY);
521 CHECK_DBL_SAME(fmax, ( 99.99, 99.87));
522 CHECK_DBL_SAME(fmax, ( -99.99, -99.87));
523 CHECK_DBL_SAME(fmax, (-987.453, 34599.87));
524 CHECK_DBL_SAME(fmax, (34599.87, -987.453));
525 CHECK_DBL_SAME(fmax, ( +0.0, -0.0));
526 CHECK_DBL_SAME(fmax, ( -0.0, +0.0));
527 CHECK_DBL_SAME(fmax, ( -0.0, -0.0));
528 CHECK_DBL_SAME(fmax, (+INFINITY, +INFINITY));
529 CHECK_DBL_SAME(fmax, (-INFINITY, -INFINITY));
530 CHECK_DBL_SAME(fmax, (+INFINITY, -INFINITY));
531 CHECK_DBL_SAME(fmax, (-INFINITY, +INFINITY));
532 CHECK_DBL_SAME(fmax, (RTStrNanDouble(NULL, true), -42.4242424242e222));
533 CHECK_DBL_SAME(fmax, (RTStrNanDouble(NULL, false), -42.4242424242e222));
534 CHECK_DBL_SAME(fmax, (-42.4242424242e-222, RTStrNanDouble(NULL, true)));
535 CHECK_DBL_SAME(fmax, (-42.4242424242e-222, RTStrNanDouble(NULL, false)));
536 CHECK_DBL_SAME(fmax, (RTStrNanDouble("2", false), RTStrNanDouble(NULL, false)));
537 CHECK_DBL_SAME(fmax, (RTStrNanDouble("3", true), RTStrNanDouble(NULL, false)));
538 CHECK_DBL_SAME(fmax, (RTStrNanDouble("4sig", true), RTStrNanDouble(NULL, false)));
539
540 CHECK_FLT(RT_NOCRT(fmaxf)( 1.0f, 1.0f), 1.0f);
541 CHECK_FLT(RT_NOCRT(fmaxf)( 4.0f, 2.0f), 4.0f);
542 CHECK_FLT(RT_NOCRT(fmaxf)( 2.0f, 4.0f), 4.0f);
543 CHECK_FLT(RT_NOCRT(fmaxf)(-2.0f, -4.0f), -2.0f);
544 CHECK_FLT(RT_NOCRT(fmaxf)(-2.0f, -4.0e-10f), -4.0e-10f);
545 CHECK_FLT(RT_NOCRT(fmaxf)(+INFINITY, +INFINITY), +INFINITY);
546 CHECK_FLT(RT_NOCRT(fmaxf)(-INFINITY, -INFINITY), -INFINITY);
547 CHECK_FLT(RT_NOCRT(fmaxf)(+INFINITY, -INFINITY), +INFINITY);
548 CHECK_FLT(RT_NOCRT(fmaxf)(-INFINITY, +INFINITY), +INFINITY);
549 CHECK_FLT_SAME(fmaxf, ( 99.99f, 99.87f));
550 CHECK_FLT_SAME(fmaxf, ( -99.99f, -99.87f));
551 CHECK_FLT_SAME(fmaxf, (-987.453f, 34599.87f));
552 CHECK_FLT_SAME(fmaxf, (34599.87f, -987.453f));
553 CHECK_FLT_SAME(fmaxf, ( +0.0f, -0.0f));
554 CHECK_FLT_SAME(fmaxf, ( -0.0f, +0.0f));
555 CHECK_FLT_SAME(fmaxf, ( -0.0f, -0.0f));
556 CHECK_FLT_SAME(fmaxf, (+INFINITY, +INFINITY));
557 CHECK_FLT_SAME(fmaxf, (-INFINITY, -INFINITY));
558 CHECK_FLT_SAME(fmaxf, (+INFINITY, -INFINITY));
559 CHECK_FLT_SAME(fmaxf, (-INFINITY, +INFINITY));
560 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat(NULL, true), -42.4242424242e22f));
561 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat(NULL, false), -42.4242424242e22f));
562 CHECK_FLT_SAME(fmaxf, (-42.42424242e-22f, RTStrNanFloat(NULL, true)));
563 CHECK_FLT_SAME(fmaxf, (-42.42424242e-22f, RTStrNanFloat(NULL, false)));
564 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat("2", false), RTStrNanFloat(NULL, false)));
565 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat("3", true), RTStrNanFloat(NULL, false)));
566 CHECK_FLT_SAME(fmaxf, (RTStrNanFloat("4sig", true), RTStrNanFloat(NULL, false)));
567
568 CHECK_LDBL(RT_NOCRT(fmaxl)( 1.0L, 1.0L), 1.0L);
569 CHECK_LDBL(RT_NOCRT(fmaxl)( 4.0L, 2.0L), 4.0L);
570 CHECK_LDBL(RT_NOCRT(fmaxl)( 2.0L, 4.0L), 4.0L);
571 CHECK_LDBL(RT_NOCRT(fmaxl)(-2.0L, -4.0L), -2.0L);
572 CHECK_LDBL(RT_NOCRT(fmaxl)(-2.0L, -4.0e-10L), -4.0e-10L);
573 CHECK_LDBL(RT_NOCRT(fmaxl)(+INFINITY, +INFINITY), +INFINITY);
574 CHECK_LDBL(RT_NOCRT(fmaxl)(-INFINITY, -INFINITY), -INFINITY);
575 CHECK_LDBL(RT_NOCRT(fmaxl)(+INFINITY, -INFINITY), +INFINITY);
576 CHECK_LDBL(RT_NOCRT(fmaxl)(-INFINITY, +INFINITY), +INFINITY);
577 CHECK_LDBL_SAME(fmaxl, ( 99.99L, 99.87L));
578 CHECK_LDBL_SAME(fmaxl, ( -99.99L, -99.87L));
579 CHECK_LDBL_SAME(fmaxl, (-987.453L, 34599.87L));
580 CHECK_LDBL_SAME(fmaxl, (34599.87L, -987.453L));
581 CHECK_LDBL_SAME(fmaxl, ( +0.0L, -0.0L));
582 CHECK_LDBL_SAME(fmaxl, ( -0.0L, +0.0L));
583 CHECK_LDBL_SAME(fmaxl, ( -0.0L, -0.0L));
584 CHECK_LDBL_SAME(fmaxl, (+INFINITY, +INFINITY));
585 CHECK_LDBL_SAME(fmaxl, (-INFINITY, -INFINITY));
586 CHECK_LDBL_SAME(fmaxl, (+INFINITY, -INFINITY));
587 CHECK_LDBL_SAME(fmaxl, (-INFINITY, +INFINITY));
588 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble(NULL, true), -42.4242424242e222L));
589 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble(NULL, false), -42.4242424242e222L));
590 CHECK_LDBL_SAME(fmaxl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, true)));
591 CHECK_LDBL_SAME(fmaxl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, false)));
592 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble("2", false), RTStrNanLongDouble(NULL, false)));
593 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble("3", true), RTStrNanLongDouble(NULL, false)));
594 CHECK_LDBL_SAME(fmaxl, (RTStrNanLongDouble("4sig", true), RTStrNanLongDouble(NULL, false)));
595}
596
597
598void testFmin()
599{
600 RTTestSub(g_hTest, "fmin[fl]");
601
602 CHECK_DBL(RT_NOCRT(fmin)( 1.0, 1.0), 1.0);
603 CHECK_DBL(RT_NOCRT(fmin)( 4.0, 2.0), 2.0);
604 CHECK_DBL(RT_NOCRT(fmin)( 2.0, 4.0), 2.0);
605 CHECK_DBL(RT_NOCRT(fmin)(-2.0, -4.0), -4.0);
606 CHECK_DBL(RT_NOCRT(fmin)(-2.0, -4.0e+10), -4.0e+10);
607 CHECK_DBL(RT_NOCRT(fmin)(+INFINITY, +INFINITY), +INFINITY);
608 CHECK_DBL(RT_NOCRT(fmin)(-INFINITY, -INFINITY), -INFINITY);
609 CHECK_DBL(RT_NOCRT(fmin)(+INFINITY, -INFINITY), -INFINITY);
610 CHECK_DBL(RT_NOCRT(fmin)(-INFINITY, +INFINITY), -INFINITY);
611 CHECK_DBL_SAME(fmin, ( 99.99, 99.87));
612 CHECK_DBL_SAME(fmin, ( -99.99, -99.87));
613 CHECK_DBL_SAME(fmin, (-987.453, 34599.87));
614 CHECK_DBL_SAME(fmin, (34599.87, -987.453));
615 CHECK_DBL_SAME(fmin, ( +0.0, -0.0));
616 CHECK_DBL_SAME(fmin, ( -0.0, +0.0));
617 CHECK_DBL_SAME(fmin, ( -0.0, -0.0));
618 CHECK_DBL_SAME(fmin, (+INFINITY, +INFINITY));
619 CHECK_DBL_SAME(fmin, (-INFINITY, -INFINITY));
620 CHECK_DBL_SAME(fmin, (+INFINITY, -INFINITY));
621 CHECK_DBL_SAME(fmin, (-INFINITY, +INFINITY));
622 CHECK_DBL_SAME(fmin, (RTStrNanDouble(NULL, true), -42.4242424242e222));
623 CHECK_DBL_SAME(fmin, (RTStrNanDouble(NULL, false), -42.4242424242e222));
624 CHECK_DBL_SAME(fmin, (-42.4242424242e-222, RTStrNanDouble(NULL, true)));
625 CHECK_DBL_SAME(fmin, (-42.4242424242e-222, RTStrNanDouble(NULL, false)));
626 CHECK_DBL_SAME(fmin, (RTStrNanDouble("2", false), RTStrNanDouble(NULL, false)));
627 CHECK_DBL_SAME(fmin, (RTStrNanDouble("3", true), RTStrNanDouble(NULL, false)));
628 CHECK_DBL_SAME(fmin, (RTStrNanDouble("4sig", true), RTStrNanDouble(NULL, false)));
629
630 CHECK_FLT(RT_NOCRT(fmin)( 1.0f, 1.0f), 1.0f);
631 CHECK_FLT(RT_NOCRT(fmin)( 4.0f, 2.0f), 2.0f);
632 CHECK_FLT(RT_NOCRT(fmin)( 2.0f, 4.0f), 2.0f);
633 CHECK_FLT(RT_NOCRT(fmin)(-2.0f, -4.0f), -4.0f);
634 CHECK_FLT(RT_NOCRT(fmin)(-2.0f, -4.0e+10f), -4.0e+10f);
635 CHECK_FLT(RT_NOCRT(fmin)(+INFINITY, +INFINITY), +INFINITY);
636 CHECK_FLT(RT_NOCRT(fmin)(-INFINITY, -INFINITY), -INFINITY);
637 CHECK_FLT(RT_NOCRT(fmin)(+INFINITY, -INFINITY), -INFINITY);
638 CHECK_FLT(RT_NOCRT(fmin)(-INFINITY, +INFINITY), -INFINITY);
639 CHECK_FLT_SAME(fminf, ( 99.99f, 99.87f));
640 CHECK_FLT_SAME(fminf, ( -99.99f, -99.87f));
641 CHECK_FLT_SAME(fminf, (-987.453f, 34599.87f));
642 CHECK_FLT_SAME(fminf, (34599.87f, -987.453f));
643 CHECK_FLT_SAME(fminf, ( +0.0f, -0.0f));
644 CHECK_FLT_SAME(fminf, ( -0.0f, +0.0f));
645 CHECK_FLT_SAME(fminf, ( -0.0f, -0.0f));
646 CHECK_FLT_SAME(fminf, (+INFINITY, +INFINITY));
647 CHECK_FLT_SAME(fminf, (-INFINITY, -INFINITY));
648 CHECK_FLT_SAME(fminf, (+INFINITY, -INFINITY));
649 CHECK_FLT_SAME(fminf, (-INFINITY, +INFINITY));
650 CHECK_FLT_SAME(fminf, (RTStrNanFloat(NULL, true), -42.4242424242e22f));
651 CHECK_FLT_SAME(fminf, (RTStrNanFloat(NULL, false), -42.4242424242e22f));
652 CHECK_FLT_SAME(fminf, (-42.42424242e-22f, RTStrNanFloat(NULL, true)));
653 CHECK_FLT_SAME(fminf, (-42.42424242e-22f, RTStrNanFloat(NULL, false)));
654 CHECK_FLT_SAME(fminf, (RTStrNanFloat("2", false), RTStrNanFloat(NULL, false)));
655 CHECK_FLT_SAME(fminf, (RTStrNanFloat("3", true), RTStrNanFloat(NULL, false)));
656 CHECK_FLT_SAME(fminf, (RTStrNanFloat("4sig", true), RTStrNanFloat(NULL, false)));
657
658 CHECK_LDBL(RT_NOCRT(fmin)( 1.0L, 1.0L), 1.0L);
659 CHECK_LDBL(RT_NOCRT(fmin)( 4.0L, 2.0L), 2.0L);
660 CHECK_LDBL(RT_NOCRT(fmin)( 2.0L, 4.0L), 2.0L);
661 CHECK_LDBL(RT_NOCRT(fmin)(-2.0L, -4.0L), -4.0L);
662 CHECK_LDBL(RT_NOCRT(fmin)(-2.0L, -4.0e+10L), -4.0e+10L);
663 CHECK_LDBL(RT_NOCRT(fmin)(+INFINITY, +INFINITY), +INFINITY);
664 CHECK_LDBL(RT_NOCRT(fmin)(-INFINITY, -INFINITY), -INFINITY);
665 CHECK_LDBL(RT_NOCRT(fmin)(+INFINITY, -INFINITY), -INFINITY);
666 CHECK_LDBL(RT_NOCRT(fmin)(-INFINITY, +INFINITY), -INFINITY);
667 CHECK_LDBL_SAME(fminl, ( 99.99L, 99.87L));
668 CHECK_LDBL_SAME(fminl, ( -99.99L, -99.87L));
669 CHECK_LDBL_SAME(fminl, (-987.453L, 34599.87L));
670 CHECK_LDBL_SAME(fminl, (34599.87L, -987.453L));
671 CHECK_LDBL_SAME(fminl, ( +0.0L, -0.0L));
672 CHECK_LDBL_SAME(fminl, ( -0.0L, +0.0L));
673 CHECK_LDBL_SAME(fminl, ( -0.0L, -0.0L));
674 CHECK_LDBL_SAME(fminl, (+INFINITY, +INFINITY));
675 CHECK_LDBL_SAME(fminl, (-INFINITY, -INFINITY));
676 CHECK_LDBL_SAME(fminl, (+INFINITY, -INFINITY));
677 CHECK_LDBL_SAME(fminl, (-INFINITY, +INFINITY));
678 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble(NULL, true), -42.4242424242e222L));
679 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble(NULL, false), -42.4242424242e222L));
680 CHECK_LDBL_SAME(fminl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, true)));
681 CHECK_LDBL_SAME(fminl, (-42.4242424242e-222L, RTStrNanLongDouble(NULL, false)));
682 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble("2", false), RTStrNanLongDouble(NULL, false)));
683 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble("3", true), RTStrNanLongDouble(NULL, false)));
684 CHECK_LDBL_SAME(fminl, (RTStrNanLongDouble("4sig", true), RTStrNanLongDouble(NULL, false)));
685}
686
687
688void testIsInf()
689{
690 RTTestSub(g_hTest, "isinf,__isinf[fl]");
691#undef isinf
692 CHECK_INT(RT_NOCRT(isinf)( 1.0), 0);
693 CHECK_INT(RT_NOCRT(isinf)( 2394.2340e200), 0);
694 CHECK_INT(RT_NOCRT(isinf)(-2394.2340e200), 0);
695 CHECK_INT(RT_NOCRT(isinf)(-INFINITY), 1);
696 CHECK_INT(RT_NOCRT(isinf)(+INFINITY), 1);
697 CHECK_INT(RT_NOCRT(isinf)(RTStrNanDouble(NULL, true)), 0);
698 CHECK_INT(RT_NOCRT(isinf)(RTStrNanDouble("4sig", false)), 0);
699
700 CHECK_INT(RT_NOCRT(__isinff)( 1.0f), 0);
701 CHECK_INT(RT_NOCRT(__isinff)( 2394.2340e20f), 0);
702 CHECK_INT(RT_NOCRT(__isinff)(-2394.2340e20f), 0);
703 CHECK_INT(RT_NOCRT(__isinff)(-INFINITY), 1);
704 CHECK_INT(RT_NOCRT(__isinff)(+INFINITY), 1);
705 CHECK_INT(RT_NOCRT(__isinff)(RTStrNanFloat(NULL, true)), 0);
706 CHECK_INT(RT_NOCRT(__isinff)(RTStrNanFloat("4sig", false)), 0);
707
708 CHECK_INT(RT_NOCRT(__isinfl)( 1.0L), 0);
709 CHECK_INT(RT_NOCRT(__isinfl)( 2394.2340e200L), 0);
710 CHECK_INT(RT_NOCRT(__isinfl)(-2394.2340e200L), 0);
711 CHECK_INT(RT_NOCRT(__isinfl)(-INFINITY), 1);
712 CHECK_INT(RT_NOCRT(__isinfl)(+INFINITY), 1);
713 CHECK_INT(RT_NOCRT(__isinfl)(RTStrNanLongDouble(NULL, true)), 0);
714 CHECK_INT(RT_NOCRT(__isinfl)(RTStrNanLongDouble("4sig", false)), 0);
715}
716
717
718void testIsNan()
719{
720 RTTestSub(g_hTest, "isnan[f],__isnanl");
721#undef isnan
722 CHECK_INT(RT_NOCRT(isnan)( 0.0), 0);
723 CHECK_INT(RT_NOCRT(isnan)( 1.0), 0);
724 CHECK_INT(RT_NOCRT(isnan)( 2394.2340e200), 0);
725 CHECK_INT(RT_NOCRT(isnan)(-2394.2340e200), 0);
726 CHECK_INT(RT_NOCRT(isnan)(-INFINITY), 0);
727 CHECK_INT(RT_NOCRT(isnan)(+INFINITY), 0);
728 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble(NULL, true)), 1);
729 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble(NULL, false)), 1);
730 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("435876quiet", false)), 1);
731 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("435876quiet", true)), 1);
732 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("678sig", false)), 1);
733 CHECK_INT(RT_NOCRT(isnan)(RTStrNanDouble("45547absig", true)), 1);
734
735 CHECK_INT(RT_NOCRT(isnanf)( 0.0f), 0);
736 CHECK_INT(RT_NOCRT(isnanf)( 1.0f), 0);
737 CHECK_INT(RT_NOCRT(isnanf)( 2394.2340e20f), 0);
738 CHECK_INT(RT_NOCRT(isnanf)(-2394.2340e20f), 0);
739 CHECK_INT(RT_NOCRT(isnanf)(-INFINITY), 0);
740 CHECK_INT(RT_NOCRT(isnanf)(+INFINITY), 0);
741 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat(NULL, true)), 1);
742 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat(NULL, false)), 1);
743 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("9560q", false)), 1);
744 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("aaaaq", true)), 1);
745 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("4sig", false)), 1);
746 CHECK_INT(RT_NOCRT(isnanf)(RTStrNanFloat("69504sig", true)), 1);
747
748 CHECK_INT(RT_NOCRT(__isnanl)( 0.0L), 0);
749 CHECK_INT(RT_NOCRT(__isnanl)( 1.0L), 0);
750 CHECK_INT(RT_NOCRT(__isnanl)( 2394.2340e200L), 0);
751 CHECK_INT(RT_NOCRT(__isnanl)(-2394.2340e200L), 0);
752 CHECK_INT(RT_NOCRT(__isnanl)(-INFINITY), 0);
753 CHECK_INT(RT_NOCRT(__isnanl)(+INFINITY), 0);
754 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble(NULL, true)), 1);
755 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble(NULL, false)), 1);
756 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("bbbbq", false)), 1);
757 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("11122q", true)), 1);
758 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("4sig", false)), 1);
759 CHECK_INT(RT_NOCRT(__isnanl)(RTStrNanLongDouble("23423406sig", true)), 1);
760}
761
762
763void testIsFinite()
764{
765 RTTestSub(g_hTest, "__isfinite[fl]");
766 CHECK_INT(RT_NOCRT(__isfinite)( 1.0), 1);
767 CHECK_INT(RT_NOCRT(__isfinite)( 2394.2340e200), 1);
768 CHECK_INT(RT_NOCRT(__isfinite)(-2394.2340e200), 1);
769 CHECK_INT(RT_NOCRT(__isfinite)(-2.1984e-310), 1); /* subnormal */
770 CHECK_INT(RT_NOCRT(__isfinite)(-INFINITY), 0);
771 CHECK_INT(RT_NOCRT(__isfinite)(+INFINITY), 0);
772 CHECK_INT(RT_NOCRT(__isfinite)(RTStrNanDouble(NULL, true)), 0);
773 CHECK_INT(RT_NOCRT(__isfinite)(RTStrNanDouble("4sig", false)), 0);
774
775 CHECK_INT(RT_NOCRT(__isfinitef)( 1.0f), 1);
776 CHECK_INT(RT_NOCRT(__isfinitef)( 2394.2340e20f), 1);
777 CHECK_INT(RT_NOCRT(__isfinitef)(-2394.2340e20f), 1);
778 CHECK_INT(RT_NOCRT(__isfinitef)(-2.1984e-40f), 1); /* subnormal */
779 CHECK_INT(RT_NOCRT(__isfinitef)(-INFINITY), 0);
780 CHECK_INT(RT_NOCRT(__isfinitef)(+INFINITY), 0);
781 CHECK_INT(RT_NOCRT(__isfinitef)(RTStrNanFloat(NULL, true)), 0);
782 CHECK_INT(RT_NOCRT(__isfinitef)(RTStrNanFloat("4sig", false)), 0);
783
784 CHECK_INT(RT_NOCRT(__isfinitel)( 1.0L), 1);
785 CHECK_INT(RT_NOCRT(__isfinitel)( 2394.2340e200L), 1);
786 CHECK_INT(RT_NOCRT(__isfinitel)(-2394.2340e200L), 1);
787#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
788 CHECK_INT(RT_NOCRT(__isfinitel)(-2.1984e-310L), 1); /* subnormal */
789#else
790 CHECK_INT(RT_NOCRT(__isfinitel)(-2.1984e-4935L), 1); /* subnormal */
791#endif
792 CHECK_INT(RT_NOCRT(__isfinitel)(-INFINITY), 0);
793 CHECK_INT(RT_NOCRT(__isfinitel)(+INFINITY), 0);
794 CHECK_INT(RT_NOCRT(__isfinitel)(RTStrNanLongDouble(NULL, true)), 0);
795 CHECK_INT(RT_NOCRT(__isfinitel)(RTStrNanLongDouble("4sig", false)), 0);
796}
797
798
799void testIsNormal()
800{
801 RTTestSub(g_hTest, "__isnormal[fl]");
802 CHECK_INT(RT_NOCRT(__isnormal)( 1.0), 1);
803 CHECK_INT(RT_NOCRT(__isnormal)( 2394.2340e200), 1);
804 CHECK_INT(RT_NOCRT(__isnormal)(-2394.2340e200), 1);
805 CHECK_INT(RT_NOCRT(__isnormal)(-2.1984e-310), 0); /* subnormal */
806 CHECK_INT(RT_NOCRT(__isnormal)(-INFINITY), 0);
807 CHECK_INT(RT_NOCRT(__isnormal)(+INFINITY), 0);
808 CHECK_INT(RT_NOCRT(__isnormal)(RTStrNanDouble(NULL, true)), 0);
809 CHECK_INT(RT_NOCRT(__isnormal)(RTStrNanDouble("4sig", false)), 0);
810
811 CHECK_INT(RT_NOCRT(__isnormalf)( 1.0f), 1);
812 CHECK_INT(RT_NOCRT(__isnormalf)( 2394.2340e20f), 1);
813 CHECK_INT(RT_NOCRT(__isnormalf)(-2394.2340e20f), 1);
814 CHECK_INT(RT_NOCRT(__isnormalf)(-2.1984e-40f), 0); /* subnormal */
815 CHECK_INT(RT_NOCRT(__isnormalf)(-INFINITY), 0);
816 CHECK_INT(RT_NOCRT(__isnormalf)(+INFINITY), 0);
817 CHECK_INT(RT_NOCRT(__isnormalf)(RTStrNanFloat(NULL, true)), 0);
818 CHECK_INT(RT_NOCRT(__isnormalf)(RTStrNanFloat("4sig", false)), 0);
819
820 CHECK_INT(RT_NOCRT(__isnormall)( 1.0L), 1);
821 CHECK_INT(RT_NOCRT(__isnormall)( 2394.2340e200L), 1);
822 CHECK_INT(RT_NOCRT(__isnormall)(-2394.2340e200L), 1);
823#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
824 CHECK_INT(RT_NOCRT(__isnormall)(-2.1984e-310L), 0); /* subnormal */
825#else
826 CHECK_INT(RT_NOCRT(__isnormall)(-2.1984e-4935L), 0); /* subnormal */
827#endif
828 CHECK_INT(RT_NOCRT(__isnormall)(-INFINITY), 0);
829 CHECK_INT(RT_NOCRT(__isnormall)(+INFINITY), 0);
830 CHECK_INT(RT_NOCRT(__isnormall)(RTStrNanLongDouble(NULL, true)), 0);
831 CHECK_INT(RT_NOCRT(__isnormall)(RTStrNanLongDouble("4sig", false)), 0);
832}
833
834
835void testFpClassify()
836{
837 RTTestSub(g_hTest, "__fpclassify[dfl]");
838 CHECK_INT(RT_NOCRT(__fpclassifyd)( +0.0), RT_NOCRT_FP_ZERO);
839 CHECK_INT(RT_NOCRT(__fpclassifyd)( -0.0), RT_NOCRT_FP_ZERO);
840 CHECK_INT(RT_NOCRT(__fpclassifyd)( 1.0), RT_NOCRT_FP_NORMAL);
841 CHECK_INT(RT_NOCRT(__fpclassifyd)( 2394.2340e200), RT_NOCRT_FP_NORMAL);
842 CHECK_INT(RT_NOCRT(__fpclassifyd)(-2394.2340e200), RT_NOCRT_FP_NORMAL);
843 CHECK_INT(RT_NOCRT(__fpclassifyd)(-2.1984e-310), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
844 CHECK_INT(RT_NOCRT(__fpclassifyd)(-INFINITY), RT_NOCRT_FP_INFINITE);
845 CHECK_INT(RT_NOCRT(__fpclassifyd)(+INFINITY), RT_NOCRT_FP_INFINITE);
846 CHECK_INT(RT_NOCRT(__fpclassifyd)(RTStrNanDouble(NULL, true)), RT_NOCRT_FP_NAN);
847 CHECK_INT(RT_NOCRT(__fpclassifyd)(RTStrNanDouble("4sig", false)), RT_NOCRT_FP_NAN);
848
849 CHECK_INT(RT_NOCRT(__fpclassifyf)( +0.0f), RT_NOCRT_FP_ZERO);
850 CHECK_INT(RT_NOCRT(__fpclassifyf)( -0.0f), RT_NOCRT_FP_ZERO);
851 CHECK_INT(RT_NOCRT(__fpclassifyf)( 1.0f), RT_NOCRT_FP_NORMAL);
852 CHECK_INT(RT_NOCRT(__fpclassifyf)( 2394.2340e20f), RT_NOCRT_FP_NORMAL);
853 CHECK_INT(RT_NOCRT(__fpclassifyf)(-2394.2340e20f), RT_NOCRT_FP_NORMAL);
854 CHECK_INT(RT_NOCRT(__fpclassifyf)(-2.1984e-40f), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
855 CHECK_INT(RT_NOCRT(__fpclassifyf)(-INFINITY), RT_NOCRT_FP_INFINITE);
856 CHECK_INT(RT_NOCRT(__fpclassifyf)(+INFINITY), RT_NOCRT_FP_INFINITE);
857 CHECK_INT(RT_NOCRT(__fpclassifyf)(RTStrNanFloat(NULL, true)), RT_NOCRT_FP_NAN);
858 CHECK_INT(RT_NOCRT(__fpclassifyf)(RTStrNanFloat("4sig", false)), RT_NOCRT_FP_NAN);
859
860 CHECK_INT(RT_NOCRT(__fpclassifyl)( +0.0L), RT_NOCRT_FP_ZERO);
861 CHECK_INT(RT_NOCRT(__fpclassifyl)( -0.0L), RT_NOCRT_FP_ZERO);
862 CHECK_INT(RT_NOCRT(__fpclassifyl)( 1.0L), RT_NOCRT_FP_NORMAL);
863 CHECK_INT(RT_NOCRT(__fpclassifyl)( 2394.2340e200L), RT_NOCRT_FP_NORMAL);
864 CHECK_INT(RT_NOCRT(__fpclassifyl)(-2394.2340e200L), RT_NOCRT_FP_NORMAL);
865#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
866 CHECK_INT(RT_NOCRT(__fpclassifyl)(-2.1984e-310L), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
867#else
868 CHECK_INT(RT_NOCRT(__fpclassifyl)(-2.1984e-4935L), RT_NOCRT_FP_SUBNORMAL); /* subnormal */
869#endif
870 CHECK_INT(RT_NOCRT(__fpclassifyl)(-INFINITY), RT_NOCRT_FP_INFINITE);
871 CHECK_INT(RT_NOCRT(__fpclassifyl)(+INFINITY), RT_NOCRT_FP_INFINITE);
872 CHECK_INT(RT_NOCRT(__fpclassifyl)(RTStrNanLongDouble(NULL, true)), RT_NOCRT_FP_NAN);
873 CHECK_INT(RT_NOCRT(__fpclassifyl)(RTStrNanLongDouble("4sig", false)), RT_NOCRT_FP_NAN);
874}
875
876
877void testSignBit()
878{
879 RTTestSub(g_hTest, "__signbit[fl]");
880 CHECK_INT(RT_NOCRT(__signbit)( +0.0), 0);
881 CHECK_INT(RT_NOCRT(__signbit)( -0.0), 1);
882 CHECK_INT(RT_NOCRT(__signbit)( 1.0), 0);
883 CHECK_INT(RT_NOCRT(__signbit)( 2394.2340e200), 0);
884 CHECK_INT(RT_NOCRT(__signbit)(-2394.2340e200), 1);
885 CHECK_INT(RT_NOCRT(__signbit)(-2.1984e-310), 1); /* subnormal */
886 CHECK_INT(RT_NOCRT(__signbit)(-INFINITY), 1);
887 CHECK_INT(RT_NOCRT(__signbit)(+INFINITY), 0);
888 CHECK_INT(RT_NOCRT(__signbit)(RTStrNanDouble(NULL, true)), 0);
889 CHECK_INT(RT_NOCRT(__signbit)(RTStrNanDouble("4sig", false)), 1);
890
891 CHECK_INT(RT_NOCRT(__signbitf)( +0.0f), 0);
892 CHECK_INT(RT_NOCRT(__signbitf)( -0.0f), 1);
893 CHECK_INT(RT_NOCRT(__signbitf)( 1.0f), 0);
894 CHECK_INT(RT_NOCRT(__signbitf)( 2394.2340e20f), 0);
895 CHECK_INT(RT_NOCRT(__signbitf)(-2394.2340e20f), 1);
896 CHECK_INT(RT_NOCRT(__signbitf)(-2.1984e-40f), 1); /* subnormal */
897 CHECK_INT(RT_NOCRT(__signbitf)(-INFINITY), 1);
898 CHECK_INT(RT_NOCRT(__signbitf)(+INFINITY), 0);
899 CHECK_INT(RT_NOCRT(__signbitf)(RTStrNanFloat(NULL, true)), 0);
900 CHECK_INT(RT_NOCRT(__signbitf)(RTStrNanFloat("4sig", false)), 1);
901
902 CHECK_INT(RT_NOCRT(__signbitl)( +0.0L), 0);
903 CHECK_INT(RT_NOCRT(__signbitl)( -0.0L), 1);
904 CHECK_INT(RT_NOCRT(__signbitl)( 1.0L), 0);
905 CHECK_INT(RT_NOCRT(__signbitl)( 2394.2340e200L), 0);
906 CHECK_INT(RT_NOCRT(__signbitl)(-2394.2340e200L), 1);
907#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
908 CHECK_INT(RT_NOCRT(__signbitl)(-2.1984e-310L), 1); /* subnormal */
909#else
910 CHECK_INT(RT_NOCRT(__signbitl)(-2.1984e-4935L), 1); /* subnormal */
911#endif
912 CHECK_INT(RT_NOCRT(__signbitl)(-INFINITY), 1);
913 CHECK_INT(RT_NOCRT(__signbitl)(+INFINITY), 0);
914 CHECK_INT(RT_NOCRT(__signbitl)(RTStrNanLongDouble(NULL, true)), 0);
915 CHECK_INT(RT_NOCRT(__signbitl)(RTStrNanLongDouble("4sig", false)), 1);
916}
917
918
919void testCeil()
920{
921 RTTestSub(g_hTest, "ceil[f]");
922 CHECK_DBL(RT_NOCRT(ceil)( +0.0), +0.0);
923 CHECK_DBL(RT_NOCRT(ceil)( -0.0), -0.0);
924 CHECK_DBL(RT_NOCRT(ceil)( -42.0), -42.0);
925 CHECK_DBL(RT_NOCRT(ceil)( -42.5), -42.0);
926 CHECK_DBL(RT_NOCRT(ceil)( +42.5), +43.0);
927 CHECK_DBL(RT_NOCRT(ceil)(-42.25), -42.0);
928 CHECK_DBL(RT_NOCRT(ceil)(+42.25), +43.0);
929 CHECK_DBL_SAME(ceil,( -0.0));
930 CHECK_DBL_SAME(ceil,( +0.0));
931 CHECK_DBL_SAME(ceil,( +42.25));
932 CHECK_DBL_SAME(ceil,(+1234.60958634e+10));
933 CHECK_DBL_SAME(ceil,(-1234.60958634e+10));
934 CHECK_DBL_SAME(ceil,( -1234.499999e+10));
935 CHECK_DBL_SAME(ceil,( -1234.499999e-10));
936 CHECK_DBL_SAME(ceil,( -2.1984e-310)); /* subnormal */
937 CHECK_DBL_SAME(ceil,(-INFINITY));
938 CHECK_DBL_SAME(ceil,(+INFINITY));
939 CHECK_DBL_SAME(ceil,(RTStrNanDouble(NULL, true)));
940 CHECK_DBL_SAME(ceil,(RTStrNanDouble("s", false)));
941
942 CHECK_DBL(RT_NOCRT(ceilf)( +0.0f), +0.0f);
943 CHECK_DBL(RT_NOCRT(ceilf)( -0.0f), -0.0f);
944 CHECK_DBL(RT_NOCRT(ceilf)( -42.0f), -42.0f);
945 CHECK_DBL(RT_NOCRT(ceilf)( -42.5f), -42.0f);
946 CHECK_DBL(RT_NOCRT(ceilf)( +42.5f), +43.0f);
947 CHECK_DBL(RT_NOCRT(ceilf)(-42.25f), -42.0f);
948 CHECK_DBL(RT_NOCRT(ceilf)(+42.25f), +43.0f);
949 CHECK_DBL_SAME(ceilf,( -0.0f));
950 CHECK_DBL_SAME(ceilf,( +0.0f));
951 CHECK_DBL_SAME(ceilf,( +42.25f));
952 CHECK_DBL_SAME(ceilf,(+1234.60958634e+10f));
953 CHECK_DBL_SAME(ceilf,(-1234.60958634e+10f));
954 CHECK_DBL_SAME(ceilf,( -1234.499999e+10f));
955 CHECK_DBL_SAME(ceilf,( -1234.499999e-10f));
956 CHECK_DBL_SAME(ceilf,( -2.1984e-40f)); /* subnormal */
957 CHECK_DBL_SAME(ceilf,(-INFINITY));
958 CHECK_DBL_SAME(ceilf,(+INFINITY));
959 CHECK_DBL_SAME(ceilf,(RTStrNanFloat(NULL, true)));
960 CHECK_DBL_SAME(ceilf,(RTStrNanFloat("s", false)));
961}
962
963
964void testFloor()
965{
966 RTTestSub(g_hTest, "floor[f]");
967 CHECK_DBL(RT_NOCRT(floor)( +0.0), +0.0);
968 CHECK_DBL(RT_NOCRT(floor)( -0.0), -0.0);
969 CHECK_DBL(RT_NOCRT(floor)( -42.0), -42.0);
970 CHECK_DBL(RT_NOCRT(floor)( -42.5), -43.0);
971 CHECK_DBL(RT_NOCRT(floor)( +42.5), +42.0);
972 CHECK_DBL(RT_NOCRT(floor)(-42.25), -43.0);
973 CHECK_DBL(RT_NOCRT(floor)(+42.25), +42.0);
974 CHECK_DBL_SAME(floor,( -0.0));
975 CHECK_DBL_SAME(floor,( +0.0));
976 CHECK_DBL_SAME(floor,( +42.25));
977 CHECK_DBL_SAME(floor,(+1234.60958634e+10));
978 CHECK_DBL_SAME(floor,(-1234.60958634e+10));
979 CHECK_DBL_SAME(floor,( -1234.499999e+10));
980 CHECK_DBL_SAME(floor,( -1234.499999e-10));
981 CHECK_DBL_SAME(floor,( -2.1984e-310)); /* subnormal */
982 CHECK_DBL_SAME(floor,(-INFINITY));
983 CHECK_DBL_SAME(floor,(+INFINITY));
984 CHECK_DBL_SAME(floor,(RTStrNanDouble(NULL, true)));
985 CHECK_DBL_SAME(floor,(RTStrNanDouble("s", false)));
986
987 CHECK_DBL(RT_NOCRT(floorf)( +0.0f), +0.0f);
988 CHECK_DBL(RT_NOCRT(floorf)( -0.0f), -0.0f);
989 CHECK_DBL(RT_NOCRT(floorf)( -42.0f), -42.0f);
990 CHECK_DBL(RT_NOCRT(floorf)( -42.5f), -43.0f);
991 CHECK_DBL(RT_NOCRT(floorf)( +42.5f), +42.0f);
992 CHECK_DBL(RT_NOCRT(floorf)(-42.25f), -43.0f);
993 CHECK_DBL(RT_NOCRT(floorf)(+42.25f), +42.0f);
994 CHECK_DBL_SAME(floorf,( -0.0f));
995 CHECK_DBL_SAME(floorf,( +0.0f));
996 CHECK_DBL_SAME(floorf,( +42.25f));
997 CHECK_DBL_SAME(floorf,(+1234.60958634e+10f));
998 CHECK_DBL_SAME(floorf,(-1234.60958634e+10f));
999 CHECK_DBL_SAME(floorf,( -1234.499999e+10f));
1000 CHECK_DBL_SAME(floorf,( -1234.499999e-10f));
1001 CHECK_DBL_SAME(floorf,( -2.1984e-40f)); /* subnormal */
1002 CHECK_DBL_SAME(floorf,(-INFINITY));
1003 CHECK_DBL_SAME(floorf,(+INFINITY));
1004 CHECK_DBL_SAME(floorf,(RTStrNanFloat(NULL, true)));
1005 CHECK_DBL_SAME(floorf,(RTStrNanFloat("s", false)));
1006}
1007
1008
1009void testTrunc()
1010{
1011 RTTestSub(g_hTest, "trunc[f]");
1012 CHECK_DBL(RT_NOCRT(trunc)( +0.0), +0.0);
1013 CHECK_DBL(RT_NOCRT(trunc)( -0.0), -0.0);
1014 CHECK_DBL(RT_NOCRT(trunc)( -42.0), -42.0);
1015 CHECK_DBL(RT_NOCRT(trunc)( -42.5), -42.0);
1016 CHECK_DBL(RT_NOCRT(trunc)( +42.5), +42.0);
1017 CHECK_DBL(RT_NOCRT(trunc)(-42.25), -42.0);
1018 CHECK_DBL(RT_NOCRT(trunc)(+42.25), +42.0);
1019 CHECK_DBL_SAME(trunc,( -0.0));
1020 CHECK_DBL_SAME(trunc,( +0.0));
1021 CHECK_DBL_SAME(trunc,( +42.25));
1022 CHECK_DBL_SAME(trunc,(+1234.60958634e+10));
1023 CHECK_DBL_SAME(trunc,(-1234.60958634e+10));
1024 CHECK_DBL_SAME(trunc,( -1234.499999e+10));
1025 CHECK_DBL_SAME(trunc,( -1234.499999e-10));
1026 CHECK_DBL_SAME(trunc,( -2.1984e-310)); /* subnormal */
1027 CHECK_DBL_SAME(trunc,(-INFINITY));
1028 CHECK_DBL_SAME(trunc,(+INFINITY));
1029 CHECK_DBL_SAME(trunc,(RTStrNanDouble(NULL, true)));
1030 CHECK_DBL_SAME(trunc,(RTStrNanDouble("s", false)));
1031
1032 CHECK_DBL(RT_NOCRT(truncf)( +0.0f), +0.0f);
1033 CHECK_DBL(RT_NOCRT(truncf)( -0.0f), -0.0f);
1034 CHECK_DBL(RT_NOCRT(truncf)( -42.0f), -42.0f);
1035 CHECK_DBL(RT_NOCRT(truncf)( -42.5f), -42.0f);
1036 CHECK_DBL(RT_NOCRT(truncf)( +42.5f), +42.0f);
1037 CHECK_DBL(RT_NOCRT(truncf)(-42.25f), -42.0f);
1038 CHECK_DBL(RT_NOCRT(truncf)(+42.25f), +42.0f);
1039 CHECK_DBL_SAME(truncf,( -0.0f));
1040 CHECK_DBL_SAME(truncf,( +0.0f));
1041 CHECK_DBL_SAME(truncf,( +42.25f));
1042 CHECK_DBL_SAME(truncf,(+1234.60958634e+10f));
1043 CHECK_DBL_SAME(truncf,(-1234.60958634e+10f));
1044 CHECK_DBL_SAME(truncf,( -1234.499999e+10f));
1045 CHECK_DBL_SAME(truncf,( -1234.499999e-10f));
1046 CHECK_DBL_SAME(truncf,( -2.1984e-40f)); /* subnormal */
1047 CHECK_DBL_SAME(truncf,(-INFINITY));
1048 CHECK_DBL_SAME(truncf,(+INFINITY));
1049 CHECK_DBL_SAME(truncf,(RTStrNanFloat(NULL, true)));
1050 CHECK_DBL_SAME(truncf,(RTStrNanFloat("s", false)));
1051}
1052
1053
1054void testRound()
1055{
1056 RTTestSub(g_hTest, "round[f]");
1057 CHECK_DBL(RT_NOCRT(round)( +0.0), +0.0);
1058 CHECK_DBL(RT_NOCRT(round)( -0.0), -0.0);
1059 CHECK_DBL(RT_NOCRT(round)( -42.0), -42.0);
1060 CHECK_DBL(RT_NOCRT(round)( -42.5), -43.0);
1061 CHECK_DBL(RT_NOCRT(round)( +42.5), +43.0);
1062 CHECK_DBL(RT_NOCRT(round)(-42.25), -42.0);
1063 CHECK_DBL(RT_NOCRT(round)(+42.25), +42.0);
1064 CHECK_DBL_SAME(round,( -0.0));
1065 CHECK_DBL_SAME(round,( +0.0));
1066 CHECK_DBL_SAME(round,( +42.25));
1067 CHECK_DBL_SAME(round,(+1234.60958634e+10));
1068 CHECK_DBL_SAME(round,(-1234.60958634e+10));
1069 CHECK_DBL_SAME(round,( -1234.499999e+10));
1070 CHECK_DBL_SAME(round,( -1234.499999e-10));
1071 CHECK_DBL_SAME(round,( -2.1984e-310)); /* subnormal */
1072 CHECK_DBL_SAME(round,(-INFINITY));
1073 CHECK_DBL_SAME(round,(+INFINITY));
1074 CHECK_DBL_SAME(round,(RTStrNanDouble(NULL, true)));
1075 CHECK_DBL_SAME(round,(RTStrNanDouble("s", false)));
1076
1077 CHECK_DBL(RT_NOCRT(roundf)( +0.0f), +0.0f);
1078 CHECK_DBL(RT_NOCRT(roundf)( -0.0f), -0.0f);
1079 CHECK_DBL(RT_NOCRT(roundf)( -42.0f), -42.0f);
1080 CHECK_DBL(RT_NOCRT(roundf)( -42.5f), -43.0f);
1081 CHECK_DBL(RT_NOCRT(roundf)( +42.5f), +43.0f);
1082 CHECK_DBL(RT_NOCRT(roundf)(-42.25f), -42.0f);
1083 CHECK_DBL(RT_NOCRT(roundf)(+42.25f), +42.0f);
1084 CHECK_DBL_SAME(roundf,( -0.0f));
1085 CHECK_DBL_SAME(roundf,( +0.0f));
1086 CHECK_DBL_SAME(roundf,( +42.25f));
1087 CHECK_DBL_SAME(roundf,(+1234.60958634e+10f));
1088 CHECK_DBL_SAME(roundf,(-1234.60958634e+10f));
1089 CHECK_DBL_SAME(roundf,( -1234.499999e+10f));
1090 CHECK_DBL_SAME(roundf,( -1234.499999e-10f));
1091 CHECK_DBL_SAME(roundf,( -2.1984e-40f)); /* subnormal */
1092 CHECK_DBL_SAME(roundf,(-INFINITY));
1093 CHECK_DBL_SAME(roundf,(+INFINITY));
1094 CHECK_DBL_SAME(roundf,(RTStrNanFloat(NULL, true)));
1095 CHECK_DBL_SAME(roundf,(RTStrNanFloat("s", false)));
1096}
1097
1098
1099void testRInt()
1100{
1101 RTTestSub(g_hTest, "rint[f]");
1102
1103 /*
1104 * Round nearest.
1105 */
1106#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
1107 AssertCompile(RT_NOCRT_FE_TONEAREST == X86_FCW_RC_NEAREST);
1108 AssertCompile(RT_NOCRT_FE_DOWNWARD == X86_FCW_RC_DOWN);
1109 AssertCompile(RT_NOCRT_FE_UPWARD == X86_FCW_RC_UP);
1110 AssertCompile(RT_NOCRT_FE_TOWARDZERO == X86_FCW_RC_ZERO);
1111 AssertCompile(RT_NOCRT_FE_ROUND_MASK == X86_FCW_RC_MASK);
1112#endif
1113 int const iSavedMode = RT_NOCRT(fegetround)();
1114 RT_NOCRT(fesetround)(FE_TONEAREST);
1115
1116 CHECK_DBL(RT_NOCRT(rint)( +0.0), +0.0);
1117 CHECK_DBL(RT_NOCRT(rint)( -0.0), -0.0);
1118 CHECK_DBL(RT_NOCRT(rint)( -42.0), -42.0);
1119 CHECK_DBL(RT_NOCRT(rint)( -42.5), -42.0);
1120 CHECK_DBL(RT_NOCRT(rint)( +42.5), +42.0);
1121 CHECK_DBL(RT_NOCRT(rint)( -43.5), -44.0);
1122 CHECK_DBL(RT_NOCRT(rint)( +43.5), +44.0);
1123 CHECK_DBL(RT_NOCRT(rint)(-42.25), -42.0);
1124 CHECK_DBL(RT_NOCRT(rint)(+42.25), +42.0);
1125 CHECK_DBL(RT_NOCRT(rint)(-42.75), -43.0);
1126 CHECK_DBL(RT_NOCRT(rint)(+42.75), +43.0);
1127 CHECK_DBL_SAME(rint,( -0.0));
1128 CHECK_DBL_SAME(rint,( +0.0));
1129 CHECK_DBL_SAME(rint,( +42.25));
1130 CHECK_DBL_SAME(rint,( +42.50));
1131 CHECK_DBL_SAME(rint,( +42.75));
1132 CHECK_DBL_SAME(rint,( -42.25));
1133 CHECK_DBL_SAME(rint,( -42.50));
1134 CHECK_DBL_SAME(rint,( -42.75));
1135 CHECK_DBL_SAME(rint,(+1234.60958634e+10));
1136 CHECK_DBL_SAME(rint,(-1234.60958634e+10));
1137 CHECK_DBL_SAME(rint,( -1234.499999e+10));
1138 CHECK_DBL_SAME(rint,( -1234.499999e-10));
1139 CHECK_DBL_SAME(rint,( -2.1984e-310)); /* subnormal */
1140 CHECK_DBL_SAME(rint,(-INFINITY));
1141 CHECK_DBL_SAME(rint,(+INFINITY));
1142 CHECK_DBL_SAME(rint,(RTStrNanDouble(NULL, true)));
1143 CHECK_DBL_SAME(rint,(RTStrNanDouble("s", false)));
1144
1145 CHECK_DBL(RT_NOCRT(rintf)( +0.0f), +0.0f);
1146 CHECK_DBL(RT_NOCRT(rintf)( -0.0f), -0.0f);
1147 CHECK_DBL(RT_NOCRT(rintf)( -42.0f), -42.0f);
1148 CHECK_DBL(RT_NOCRT(rintf)( -42.5f), -42.0f);
1149 CHECK_DBL(RT_NOCRT(rintf)( +42.5f), +42.0f);
1150 CHECK_DBL(RT_NOCRT(rintf)( -43.5f), -44.0f);
1151 CHECK_DBL(RT_NOCRT(rintf)( +43.5f), +44.0f);
1152 CHECK_DBL(RT_NOCRT(rintf)(-42.25f), -42.0f);
1153 CHECK_DBL(RT_NOCRT(rintf)(+42.25f), +42.0f);
1154 CHECK_DBL_SAME(rintf,( -0.0f));
1155 CHECK_DBL_SAME(rintf,( +0.0f));
1156 CHECK_DBL_SAME(rintf,( +42.25f));
1157 CHECK_DBL_SAME(rintf,( +42.50f));
1158 CHECK_DBL_SAME(rintf,( +42.75f));
1159 CHECK_DBL_SAME(rintf,( -42.25f));
1160 CHECK_DBL_SAME(rintf,( -42.50f));
1161 CHECK_DBL_SAME(rintf,( -42.75f));
1162 CHECK_DBL_SAME(rintf,(+1234.60958634e+10f));
1163 CHECK_DBL_SAME(rintf,(-1234.60958634e+10f));
1164 CHECK_DBL_SAME(rintf,( -1234.499999e+10f));
1165 CHECK_DBL_SAME(rintf,( -1234.499999e-10f));
1166 CHECK_DBL_SAME(rintf,( -2.1984e-40f)); /* subnormal */
1167 CHECK_DBL_SAME(rintf,(-INFINITY));
1168 CHECK_DBL_SAME(rintf,(+INFINITY));
1169 CHECK_DBL_SAME(rintf,(RTStrNanFloat(NULL, true)));
1170 CHECK_DBL_SAME(rintf,(RTStrNanFloat("s", false)));
1171
1172 /*
1173 * Round UP.
1174 */
1175 RT_NOCRT(fesetround)(FE_UPWARD);
1176
1177 CHECK_DBL(RT_NOCRT(rint)( +0.0), +0.0);
1178 CHECK_DBL(RT_NOCRT(rint)( -0.0), -0.0);
1179 CHECK_DBL(RT_NOCRT(rint)( -42.0), -42.0);
1180 CHECK_DBL(RT_NOCRT(rint)( -42.5), -42.0);
1181 CHECK_DBL(RT_NOCRT(rint)( +42.5), +43.0);
1182 CHECK_DBL(RT_NOCRT(rint)( -43.5), -43.0);
1183 CHECK_DBL(RT_NOCRT(rint)( +43.5), +44.0);
1184 CHECK_DBL(RT_NOCRT(rint)(-42.25), -42.0);
1185 CHECK_DBL(RT_NOCRT(rint)(+42.25), +43.0);
1186 CHECK_DBL(RT_NOCRT(rint)(-42.75), -42.0);
1187 CHECK_DBL(RT_NOCRT(rint)(+42.75), +43.0);
1188 CHECK_DBL_SAME(rint,( -0.0));
1189 CHECK_DBL_SAME(rint,( +0.0));
1190 CHECK_DBL_SAME(rint,( +42.25));
1191 CHECK_DBL_SAME(rint,( +42.50));
1192 CHECK_DBL_SAME(rint,( +42.75));
1193 CHECK_DBL_SAME(rint,( -42.25));
1194 CHECK_DBL_SAME(rint,( -42.50));
1195 CHECK_DBL_SAME(rint,( -42.75));
1196 CHECK_DBL_SAME(rint,(+1234.60958634e+10));
1197 CHECK_DBL_SAME(rint,(-1234.60958634e+10));
1198 CHECK_DBL_SAME(rint,( -1234.499999e+10));
1199 CHECK_DBL_SAME(rint,( -1234.499999e-10));
1200 CHECK_DBL_SAME(rint,( -2.1984e-310)); /* subnormal */
1201 CHECK_DBL_SAME(rint,(-INFINITY));
1202 CHECK_DBL_SAME(rint,(+INFINITY));
1203 CHECK_DBL_SAME(rint,(RTStrNanDouble(NULL, true)));
1204 CHECK_DBL_SAME(rint,(RTStrNanDouble("s", false)));
1205
1206 CHECK_DBL(RT_NOCRT(rintf)( +0.0f), +0.0f);
1207 CHECK_DBL(RT_NOCRT(rintf)( -0.0f), -0.0f);
1208 CHECK_DBL(RT_NOCRT(rintf)( -42.0f), -42.0f);
1209 CHECK_DBL(RT_NOCRT(rintf)( -42.5f), -42.0f);
1210 CHECK_DBL(RT_NOCRT(rintf)( +42.5f), +43.0f);
1211 CHECK_DBL(RT_NOCRT(rintf)( -43.5f), -43.0f);
1212 CHECK_DBL(RT_NOCRT(rintf)( +43.5f), +44.0f);
1213 CHECK_DBL(RT_NOCRT(rintf)(-42.25f), -42.0f);
1214 CHECK_DBL(RT_NOCRT(rintf)(+42.25f), +43.0f);
1215 CHECK_DBL_SAME(rintf,( -0.0f));
1216 CHECK_DBL_SAME(rintf,( +0.0f));
1217 CHECK_DBL_SAME(rintf,( +42.25f));
1218 CHECK_DBL_SAME(rintf,( +42.50f));
1219 CHECK_DBL_SAME(rintf,( +42.75f));
1220 CHECK_DBL_SAME(rintf,( -42.25f));
1221 CHECK_DBL_SAME(rintf,( -42.50f));
1222 CHECK_DBL_SAME(rintf,( -42.75f));
1223 CHECK_DBL_SAME(rintf,(+1234.60958634e+10f));
1224 CHECK_DBL_SAME(rintf,(-1234.60958634e+10f));
1225 CHECK_DBL_SAME(rintf,( -1234.499999e+10f));
1226 CHECK_DBL_SAME(rintf,( -1234.499999e-10f));
1227 CHECK_DBL_SAME(rintf,( -2.1984e-40f)); /* subnormal */
1228 CHECK_DBL_SAME(rintf,(-INFINITY));
1229 CHECK_DBL_SAME(rintf,(+INFINITY));
1230 CHECK_DBL_SAME(rintf,(RTStrNanFloat(NULL, true)));
1231 CHECK_DBL_SAME(rintf,(RTStrNanFloat("s", false)));
1232
1233 /*
1234 * Round DOWN.
1235 */
1236 RT_NOCRT(fesetround)(FE_DOWNWARD);
1237
1238 CHECK_DBL(RT_NOCRT(rint)( +0.0), +0.0);
1239 CHECK_DBL(RT_NOCRT(rint)( -0.0), -0.0);
1240 CHECK_DBL(RT_NOCRT(rint)( -42.0), -42.0);
1241 CHECK_DBL(RT_NOCRT(rint)( -42.5), -43.0);
1242 CHECK_DBL(RT_NOCRT(rint)( +42.5), +42.0);
1243 CHECK_DBL(RT_NOCRT(rint)( -43.5), -44.0);
1244 CHECK_DBL(RT_NOCRT(rint)( +43.5), +43.0);
1245 CHECK_DBL(RT_NOCRT(rint)(-42.25), -43.0);
1246 CHECK_DBL(RT_NOCRT(rint)(+42.25), +42.0);
1247 CHECK_DBL(RT_NOCRT(rint)(-42.75), -43.0);
1248 CHECK_DBL(RT_NOCRT(rint)(+42.75), +42.0);
1249 CHECK_DBL_SAME(rint,( -0.0));
1250 CHECK_DBL_SAME(rint,( +0.0));
1251 CHECK_DBL_SAME(rint,( +42.25));
1252 CHECK_DBL_SAME(rint,( +42.50));
1253 CHECK_DBL_SAME(rint,( +42.75));
1254 CHECK_DBL_SAME(rint,( -42.25));
1255 CHECK_DBL_SAME(rint,( -42.50));
1256 CHECK_DBL_SAME(rint,( -42.75));
1257 CHECK_DBL_SAME(rint,(+1234.60958634e+10));
1258 CHECK_DBL_SAME(rint,(-1234.60958634e+10));
1259 CHECK_DBL_SAME(rint,( -1234.499999e+10));
1260 CHECK_DBL_SAME(rint,( -1234.499999e-10));
1261 CHECK_DBL_SAME(rint,( -2.1984e-310)); /* subnormal */
1262 CHECK_DBL_SAME(rint,(-INFINITY));
1263 CHECK_DBL_SAME(rint,(+INFINITY));
1264 CHECK_DBL_SAME(rint,(RTStrNanDouble(NULL, true)));
1265 CHECK_DBL_SAME(rint,(RTStrNanDouble("s", false)));
1266
1267 CHECK_DBL(RT_NOCRT(rintf)( +0.0f), +0.0f);
1268 CHECK_DBL(RT_NOCRT(rintf)( -0.0f), -0.0f);
1269 CHECK_DBL(RT_NOCRT(rintf)( -42.0f), -42.0f);
1270 CHECK_DBL(RT_NOCRT(rintf)( -42.5f), -43.0f);
1271 CHECK_DBL(RT_NOCRT(rintf)( +42.5f), +42.0f);
1272 CHECK_DBL(RT_NOCRT(rintf)( -43.5f), -44.0f);
1273 CHECK_DBL(RT_NOCRT(rintf)( +43.5f), +43.0f);
1274 CHECK_DBL(RT_NOCRT(rintf)(-42.25f), -43.0f);
1275 CHECK_DBL(RT_NOCRT(rintf)(+42.25f), +42.0f);
1276 CHECK_DBL_SAME(rintf,( -0.0f));
1277 CHECK_DBL_SAME(rintf,( +0.0f));
1278 CHECK_DBL_SAME(rintf,( +42.25f));
1279 CHECK_DBL_SAME(rintf,( +42.50f));
1280 CHECK_DBL_SAME(rintf,( +42.75f));
1281 CHECK_DBL_SAME(rintf,( -42.25f));
1282 CHECK_DBL_SAME(rintf,( -42.50f));
1283 CHECK_DBL_SAME(rintf,( -42.75f));
1284 CHECK_DBL_SAME(rintf,(+1234.60958634e+10f));
1285 CHECK_DBL_SAME(rintf,(-1234.60958634e+10f));
1286 CHECK_DBL_SAME(rintf,( -1234.499999e+10f));
1287 CHECK_DBL_SAME(rintf,( -1234.499999e-10f));
1288 CHECK_DBL_SAME(rintf,( -2.1984e-40f)); /* subnormal */
1289 CHECK_DBL_SAME(rintf,(-INFINITY));
1290 CHECK_DBL_SAME(rintf,(+INFINITY));
1291 CHECK_DBL_SAME(rintf,(RTStrNanFloat(NULL, true)));
1292 CHECK_DBL_SAME(rintf,(RTStrNanFloat("s", false)));
1293
1294 /*
1295 * Round towards ZERO.
1296 */
1297 RT_NOCRT(fesetround)(FE_TOWARDZERO);
1298
1299 CHECK_DBL(RT_NOCRT(rint)( +0.0), +0.0);
1300 CHECK_DBL(RT_NOCRT(rint)( -0.0), -0.0);
1301 CHECK_DBL(RT_NOCRT(rint)( -42.0), -42.0);
1302 CHECK_DBL(RT_NOCRT(rint)( -42.5), -42.0);
1303 CHECK_DBL(RT_NOCRT(rint)( +42.5), +42.0);
1304 CHECK_DBL(RT_NOCRT(rint)( -43.5), -43.0);
1305 CHECK_DBL(RT_NOCRT(rint)( +43.5), +43.0);
1306 CHECK_DBL(RT_NOCRT(rint)(-42.25), -42.0);
1307 CHECK_DBL(RT_NOCRT(rint)(+42.25), +42.0);
1308 CHECK_DBL(RT_NOCRT(rint)(-42.75), -42.0);
1309 CHECK_DBL(RT_NOCRT(rint)(+42.75), +42.0);
1310 CHECK_DBL_SAME(rint,( -0.0));
1311 CHECK_DBL_SAME(rint,( +0.0));
1312 CHECK_DBL_SAME(rint,( +42.25));
1313 CHECK_DBL_SAME(rint,( +42.50));
1314 CHECK_DBL_SAME(rint,( +42.75));
1315 CHECK_DBL_SAME(rint,( -42.25));
1316 CHECK_DBL_SAME(rint,( -42.50));
1317 CHECK_DBL_SAME(rint,( -42.75));
1318 CHECK_DBL_SAME(rint,(+1234.60958634e+10));
1319 CHECK_DBL_SAME(rint,(-1234.60958634e+10));
1320 CHECK_DBL_SAME(rint,( -1234.499999e+10));
1321 CHECK_DBL_SAME(rint,( -1234.499999e-10));
1322 CHECK_DBL_SAME(rint,( -2.1984e-310)); /* subnormal */
1323 CHECK_DBL_SAME(rint,(-INFINITY));
1324 CHECK_DBL_SAME(rint,(+INFINITY));
1325 CHECK_DBL_SAME(rint,(RTStrNanDouble(NULL, true)));
1326 CHECK_DBL_SAME(rint,(RTStrNanDouble("s", false)));
1327
1328 CHECK_DBL(RT_NOCRT(rintf)( +0.0f), +0.0f);
1329 CHECK_DBL(RT_NOCRT(rintf)( -0.0f), -0.0f);
1330 CHECK_DBL(RT_NOCRT(rintf)( -42.0f), -42.0f);
1331 CHECK_DBL(RT_NOCRT(rintf)( -42.5f), -42.0f);
1332 CHECK_DBL(RT_NOCRT(rintf)( +42.5f), +42.0f);
1333 CHECK_DBL(RT_NOCRT(rintf)( -43.5f), -43.0f);
1334 CHECK_DBL(RT_NOCRT(rintf)( +43.5f), +43.0f);
1335 CHECK_DBL(RT_NOCRT(rintf)(-42.25f), -42.0f);
1336 CHECK_DBL(RT_NOCRT(rintf)(+42.25f), +42.0f);
1337 CHECK_DBL_SAME(rintf,( -0.0f));
1338 CHECK_DBL_SAME(rintf,( +0.0f));
1339 CHECK_DBL_SAME(rintf,( +42.25f));
1340 CHECK_DBL_SAME(rintf,( +42.50f));
1341 CHECK_DBL_SAME(rintf,( +42.75f));
1342 CHECK_DBL_SAME(rintf,( -42.25f));
1343 CHECK_DBL_SAME(rintf,( -42.50f));
1344 CHECK_DBL_SAME(rintf,( -42.75f));
1345 CHECK_DBL_SAME(rintf,(+1234.60958634e+10f));
1346 CHECK_DBL_SAME(rintf,(-1234.60958634e+10f));
1347 CHECK_DBL_SAME(rintf,( -1234.499999e+10f));
1348 CHECK_DBL_SAME(rintf,( -1234.499999e-10f));
1349 CHECK_DBL_SAME(rintf,( -2.1984e-40f)); /* subnormal */
1350 CHECK_DBL_SAME(rintf,(-INFINITY));
1351 CHECK_DBL_SAME(rintf,(+INFINITY));
1352 CHECK_DBL_SAME(rintf,(RTStrNanFloat(NULL, true)));
1353 CHECK_DBL_SAME(rintf,(RTStrNanFloat("s", false)));
1354
1355 RT_NOCRT(fesetround)(iSavedMode);
1356}
1357
1358
1359void testLRound()
1360{
1361 RTTestSub(g_hTest, "lround[f]");
1362 CHECK_LONG(RT_NOCRT(lround)( +0.0), 0);
1363 CHECK_LONG(RT_NOCRT(lround)( -0.0), 0);
1364 CHECK_LONG(RT_NOCRT(lround)( -42.0), -42);
1365 CHECK_LONG(RT_NOCRT(lround)( -42.5), -43);
1366 CHECK_LONG(RT_NOCRT(lround)( +42.5), +43);
1367 CHECK_LONG(RT_NOCRT(lround)( -42.25), -42);
1368 CHECK_LONG(RT_NOCRT(lround)( +42.25), +42);
1369 CHECK_LONG(RT_NOCRT(lround)(+1234.60958634e+20), LONG_MAX);
1370 CHECK_LONG(RT_NOCRT(lround)(-1234.60958634e+20), LONG_MIN);
1371 CHECK_LONG(RT_NOCRT(lround)( -1234.499999e+20), LONG_MIN);
1372 CHECK_LONG(RT_NOCRT(lround)( -1234.499999e-10), 0);
1373 CHECK_LONG(RT_NOCRT(lround)( -2.1984e-310), 0); /* subnormal */
1374 CHECK_LONG(RT_NOCRT(lround)(-INFINITY), LONG_MIN);
1375 CHECK_LONG(RT_NOCRT(lround)(+INFINITY), LONG_MAX);
1376 CHECK_LONG(RT_NOCRT(lround)(RTStrNanDouble(NULL, true)), LONG_MAX);
1377 CHECK_LONG(RT_NOCRT(lround)(RTStrNanDouble("s", false)), LONG_MAX);
1378 CHECK_LONG_SAME(lround,( -0.0));
1379 CHECK_LONG_SAME(lround,( +0.0));
1380 CHECK_LONG_SAME(lround,( +42.25));
1381 CHECK_LONG_SAME(lround,( +42.25e+6));
1382 CHECK_LONG_SAME(lround,( -42.25e+6));
1383 CHECK_LONG_SAME(lround,( -1234.499999e-10));
1384 CHECK_LONG_SAME(lround,( -2.1984e-310)); /* subnormal */
1385#if 0 /* unspecified, we test our expected behavior above */
1386 CHECK_LONG_SAME(lround,(+1234.60958634e+20));
1387 CHECK_LONG_SAME(lround,(-1234.60958634e+20));
1388 CHECK_LONG_SAME(lround,( -1234.499999e+20));
1389 CHECK_LONG_SAME(lround,(-INFINITY));
1390 CHECK_LONG_SAME(lround,(+INFINITY));
1391 CHECK_LONG_SAME(lround,(RTStrNanDouble(NULL, true)));
1392 CHECK_LONG_SAME(lround,(RTStrNanDouble("s", false)));
1393#endif
1394
1395 CHECK_LONG(RT_NOCRT(lroundf)( +0.0f), 0);
1396 CHECK_LONG(RT_NOCRT(lroundf)( -0.0f), 0);
1397 CHECK_LONG(RT_NOCRT(lroundf)( -42.0f), -42);
1398 CHECK_LONG(RT_NOCRT(lroundf)( -42.5f), -43);
1399 CHECK_LONG(RT_NOCRT(lroundf)( +42.5f), +43);
1400 CHECK_LONG(RT_NOCRT(lroundf)( -42.25f), -42);
1401 CHECK_LONG(RT_NOCRT(lroundf)( +42.25f), +42);
1402 CHECK_LONG(RT_NOCRT(lroundf)(+1234.60958634e+20f), LONG_MAX);
1403 CHECK_LONG(RT_NOCRT(lroundf)(-1234.60958634e+20f), LONG_MIN);
1404 CHECK_LONG(RT_NOCRT(lroundf)( -1234.499999e+20f), LONG_MIN);
1405 CHECK_LONG(RT_NOCRT(lroundf)( -1234.499999e-10f), 0);
1406 CHECK_LONG(RT_NOCRT(lroundf)( -2.1984e-40f), 0); /* subnormal */
1407 CHECK_LONG(RT_NOCRT(lroundf)(-INFINITY), LONG_MIN);
1408 CHECK_LONG(RT_NOCRT(lroundf)(+INFINITY), LONG_MAX);
1409 CHECK_LONG(RT_NOCRT(lroundf)(RTStrNanFloat(NULL, true)), LONG_MAX);
1410 CHECK_LONG(RT_NOCRT(lroundf)(RTStrNanFloat("s", false)), LONG_MAX);
1411 CHECK_LONG_SAME(lroundf,( -0.0f));
1412 CHECK_LONG_SAME(lroundf,( +0.0f));
1413 CHECK_LONG_SAME(lroundf,( +42.25f));
1414 CHECK_LONG_SAME(lroundf,( +42.25e+6f));
1415 CHECK_LONG_SAME(lroundf,( -42.25e+6f));
1416 CHECK_LONG_SAME(lroundf,( -1234.499999e-10f));
1417 CHECK_LONG_SAME(lroundf,( -2.1984e-40f)); /* subnormal */
1418#if 0 /* unspecified, we test our expected behavior above */
1419 CHECK_LONG_SAME(lroundf,(+1234.60958634e+20f));
1420 CHECK_LONG_SAME(lroundf,(-1234.60958634e+20f));
1421 CHECK_LONG_SAME(lroundf,( -1234.499999e+20f));
1422 CHECK_LONG_SAME(lroundf,(-INFINITY));
1423 CHECK_LONG_SAME(lroundf,(+INFINITY));
1424 CHECK_LONG_SAME(lroundf,(RTStrNanFloat(NULL, true)));
1425 CHECK_LONG_SAME(lroundf,(RTStrNanFloat("s", false)));
1426#endif
1427}
1428
1429
1430void testLLRound()
1431{
1432 RTTestSub(g_hTest, "llround[f]");
1433 CHECK_LLONG(RT_NOCRT(llround)( +0.0), 0);
1434 CHECK_LLONG(RT_NOCRT(llround)( -0.0), 0);
1435 CHECK_LLONG(RT_NOCRT(llround)( -42.0), -42);
1436 CHECK_LLONG(RT_NOCRT(llround)( -42.5), -43);
1437 CHECK_LLONG(RT_NOCRT(llround)( +42.5), +43);
1438 CHECK_LLONG(RT_NOCRT(llround)(-42.25), -42);
1439 CHECK_LLONG(RT_NOCRT(llround)(+42.25), +42);
1440 CHECK_LLONG(RT_NOCRT(llround)(+42.25e4), +422500);
1441 CHECK_LLONG(RT_NOCRT(llround)(+42.25e12), +42250000000000LL);
1442 CHECK_LLONG(RT_NOCRT(llround)(+1234.60958634e+20), LLONG_MAX);
1443 CHECK_LLONG(RT_NOCRT(llround)(-1234.60958634e+20), LLONG_MIN);
1444 CHECK_LLONG(RT_NOCRT(llround)( -1234.499999e+20), LLONG_MIN);
1445 CHECK_LLONG(RT_NOCRT(llround)( -1234.499999e-10), 0);
1446 CHECK_LLONG(RT_NOCRT(llround)( -2.1984e-310), 0); /* subnormal */
1447 CHECK_LLONG(RT_NOCRT(llround)(-INFINITY), LLONG_MIN);
1448 CHECK_LLONG(RT_NOCRT(llround)(+INFINITY), LLONG_MAX);
1449 CHECK_LLONG(RT_NOCRT(llround)(RTStrNanDouble(NULL, true)), LLONG_MAX);
1450 CHECK_LLONG(RT_NOCRT(llround)(RTStrNanDouble("s", false)), LLONG_MAX);
1451 CHECK_LLONG_SAME(llround,( -0.0));
1452 CHECK_LLONG_SAME(llround,( +0.0));
1453 CHECK_LLONG_SAME(llround,( +42.25));
1454 CHECK_LLONG_SAME(llround,( +42.25e+6));
1455 CHECK_LLONG_SAME(llround,( -42.25e+6));
1456 CHECK_LLONG_SAME(llround,( -42.25e+12));
1457 CHECK_LLONG_SAME(llround,( +42.265785e+13));
1458 CHECK_LLONG_SAME(llround,( -1234.499999e-10));
1459 CHECK_LLONG_SAME(llround,( -2.1984e-310)); /* subnormal */
1460#if 0 /* unspecified, we test our expected behavior above */
1461 CHECK_LLONG_SAME(llround,(+1234.60958634e+20));
1462 CHECK_LLONG_SAME(llround,(-1234.60958634e+20));
1463 CHECK_LLONG_SAME(llround,( -1234.499999e+20));
1464 CHECK_LLONG_SAME(llround,(-INFINITY));
1465 CHECK_LLONG_SAME(llround,(+INFINITY));
1466 CHECK_LLONG_SAME(llround,(RTStrNanDouble(NULL, true)));
1467 CHECK_LLONG_SAME(llround,(RTStrNanDouble("s", false)));
1468#endif
1469
1470 CHECK_LLONG(RT_NOCRT(llroundf)( +0.0f), 0);
1471 CHECK_LLONG(RT_NOCRT(llroundf)( -0.0f), 0);
1472 CHECK_LLONG(RT_NOCRT(llroundf)( -42.0f), -42);
1473 CHECK_LLONG(RT_NOCRT(llroundf)( -42.5f), -43);
1474 CHECK_LLONG(RT_NOCRT(llroundf)( +42.5f), +43);
1475 CHECK_LLONG(RT_NOCRT(llroundf)(-42.25f), -42);
1476 CHECK_LLONG(RT_NOCRT(llroundf)(+42.25f), +42);
1477 CHECK_LLONG(RT_NOCRT(llroundf)(+42.25e4f), +422500);
1478 CHECK_LLONG(RT_NOCRT(llroundf)(+42.24e10f), +422400000000LL);
1479 CHECK_LLONG(RT_NOCRT(llroundf)(+1234.60958634e+20f), LLONG_MAX);
1480 CHECK_LLONG(RT_NOCRT(llroundf)(-1234.60958634e+20f), LLONG_MIN);
1481 CHECK_LLONG(RT_NOCRT(llroundf)( -1234.499999e+20f), LLONG_MIN);
1482 CHECK_LLONG(RT_NOCRT(llroundf)( -1234.499999e-10f), 0);
1483 CHECK_LLONG(RT_NOCRT(llroundf)( -2.1984e-40f), 0); /* subnormal */
1484 CHECK_LLONG(RT_NOCRT(llroundf)(-INFINITY), LLONG_MIN);
1485 CHECK_LLONG(RT_NOCRT(llroundf)(+INFINITY), LLONG_MAX);
1486 CHECK_LLONG(RT_NOCRT(llroundf)(RTStrNanFloat(NULL, true)), LLONG_MAX);
1487 CHECK_LLONG(RT_NOCRT(llroundf)(RTStrNanFloat("s", false)), LLONG_MAX);
1488 CHECK_LLONG_SAME(llroundf,( -0.0f));
1489 CHECK_LLONG_SAME(llroundf,( +0.0f));
1490 CHECK_LLONG_SAME(llroundf,( +42.25f));
1491 CHECK_LLONG_SAME(llroundf,( +42.25e+6f));
1492 CHECK_LLONG_SAME(llroundf,( -42.25e+6f));
1493 CHECK_LLONG_SAME(llroundf,( -42.25e+12f));
1494 CHECK_LLONG_SAME(llroundf,( +42.265785e+13f));
1495 CHECK_LLONG_SAME(llroundf,( -1234.499999e-10f));
1496 CHECK_LLONG_SAME(llroundf,( -2.1984e-40f)); /* subnormal */
1497#if 0 /* unspecified, we test our expected behavior above */
1498 CHECK_LLONG_SAME(llroundf,(+1234.60958634e+20f));
1499 CHECK_LLONG_SAME(llroundf,(-1234.60958634e+20f));
1500 CHECK_LLONG_SAME(llroundf,( -1234.499999e+20f));
1501 CHECK_LLONG_SAME(llroundf,(-INFINITY));
1502 CHECK_LLONG_SAME(llroundf,(+INFINITY));
1503 CHECK_LLONG_SAME(llroundf,(RTStrNanFloat(NULL, true)));
1504 CHECK_LLONG_SAME(llroundf,(RTStrNanFloat("s", false)));
1505#endif
1506
1507#if 0
1508 CHECK_LLONG(RT_NOCRT(llroundl)( +0.0L), 0);
1509 CHECK_LLONG(RT_NOCRT(llroundl)( -0.0L), 0);
1510 CHECK_LLONG(RT_NOCRT(llroundl)( -42.0L), -42);
1511 CHECK_LLONG(RT_NOCRT(llroundl)( -42.5L), -43);
1512 CHECK_LLONG(RT_NOCRT(llroundl)( +42.5L), +43);
1513 CHECK_LLONG(RT_NOCRT(llroundl)(-42.25L), -42);
1514 CHECK_LLONG(RT_NOCRT(llroundl)(+42.25L), +42);
1515 CHECK_LLONG(RT_NOCRT(llroundl)(+42.25e4L), +422500);
1516 CHECK_LLONG(RT_NOCRT(llroundl)(+42.24e12L), +42240000000000LL);
1517 CHECK_LLONG(RT_NOCRT(llroundl)(+1234.60958634e+20L), LLONG_MAX);
1518 CHECK_LLONG(RT_NOCRT(llroundl)(-1234.60958634e+20L), LLONG_MIN);
1519 CHECK_LLONG(RT_NOCRT(llroundl)( -1234.499999e+20L), LLONG_MIN);
1520 CHECK_LLONG(RT_NOCRT(llroundl)( -1234.499999e-10L), 0);
1521#ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
1522 CHECK_LLONG(RT_NOCRT(llroundl)( -2.1984e-310L), 0); /* subnormal */
1523#else
1524 CHECK_LLONG(RT_NOCRT(llroundl)( -2.1984e-4935L), 0); /* subnormal */
1525#endif
1526 CHECK_LLONG(RT_NOCRT(llroundl)(-INFINITY), LLONG_MIN);
1527 CHECK_LLONG(RT_NOCRT(llroundl)(+INFINITY), LLONG_MAX);
1528 CHECK_LLONG(RT_NOCRT(llroundl)(RTStrNanLongDouble(NULL, true)), LLONG_MAX);
1529 CHECK_LLONG(RT_NOCRT(llroundl)(RTStrNanLongDouble("s", false)), LLONG_MAX);
1530 CHECK_LLONG_SAME(llroundl,( -0.0));
1531 CHECK_LLONG_SAME(llroundl,( +0.0));
1532 CHECK_LLONG_SAME(llroundl,( +42.25));
1533 CHECK_LLONG_SAME(llroundl,( +42.25e+6));
1534 CHECK_LLONG_SAME(llroundl,( -42.25e+6));
1535 CHECK_LLONG_SAME(llroundl,( -42.25e+12));
1536 CHECK_LLONG_SAME(llroundl,( +42.265785e+13));
1537 CHECK_LLONG_SAME(llroundl,( -1234.499999e-10L));
1538# ifdef RT_COMPILER_WITH_64BIT_LONG_DOUBLE
1539 CHECK_LLONG_SAME(llroundl,( -2.1984e-310L)); /* subnormal */
1540# else
1541 CHECK_LLONG_SAME(llroundl,( -2.1984e-4935L)); /* subnormal */
1542# endif
1543#if 0 /* unspecified, we test our expected behavior above */
1544 CHECK_LLONG_SAME(llroundl,(+1234.60958634e+20L));
1545 CHECK_LLONG_SAME(llroundl,(-1234.60958634e+20L));
1546 CHECK_LLONG_SAME(llroundl,( -1234.499999e+20L));
1547 CHECK_LLONG_SAME(llroundl,(-INFINITY));
1548 CHECK_LLONG_SAME(llroundl,(+INFINITY));
1549 CHECK_LLONG_SAME(llroundl,(RTStrNanLongDouble(NULL, true)));
1550 CHECK_LLONG_SAME(llroundl,(RTStrNanLongDouble("s", false)));
1551#endif
1552#endif
1553}
1554
1555
1556int main()
1557{
1558 RTEXITCODE rcExit = RTTestInitAndCreate("tstRTNoCrt-2", &g_hTest);
1559 if (rcExit != RTEXITCODE_SUCCESS)
1560 return rcExit;
1561
1562 /* Some preconditions: */
1563 RTFLOAT32U r32;
1564 r32.r = RTStrNanFloat("s", false);
1565 RTTEST_CHECK(g_hTest, RTFLOAT32U_IS_SIGNALLING_NAN(&r32));
1566 r32.r = RTStrNanFloat("q", false);
1567 RTTEST_CHECK(g_hTest, RTFLOAT32U_IS_QUIET_NAN(&r32));
1568 r32.r = RTStrNanFloat(NULL, false);
1569 RTTEST_CHECK(g_hTest, RTFLOAT32U_IS_QUIET_NAN(&r32));
1570
1571 RTFLOAT64U r64;
1572 r64.r = RTStrNanDouble("s", false);
1573 RTTEST_CHECK(g_hTest, RTFLOAT64U_IS_SIGNALLING_NAN(&r64));
1574 r64.r = RTStrNanDouble("q", false);
1575 RTTEST_CHECK(g_hTest, RTFLOAT64U_IS_QUIET_NAN(&r64));
1576 r64.r = RTStrNanDouble(NULL, false);
1577 RTTEST_CHECK(g_hTest, RTFLOAT64U_IS_QUIET_NAN(&r64));
1578
1579 /* stdlib.h (integer) */
1580 testAbs();
1581
1582 /* math.h */
1583 testCopySign();
1584 testExp2();
1585 testFma();
1586 testFmax();
1587 testFmin();
1588 testIsInf();
1589 testIsNan();
1590 testIsFinite();
1591 testIsNormal();
1592 testFpClassify();
1593 testSignBit();
1594 testCeil();
1595 testFloor();
1596 testTrunc();
1597 testRound();
1598 testRInt();
1599 testLRound();
1600 testLLRound();
1601
1602#if 0
1603 ../common/math/atan.asm \
1604 ../common/math/atan2.asm \
1605 ../common/math/atan2f.asm \
1606 ../common/math/atanf.asm \
1607 ../common/math/cos.asm \
1608 ../common/math/cosf.asm \
1609 ../common/math/cosl.asm \
1610 ../common/math/exp2.asm \
1611 ../common/math/exp2f.asm \
1612 ../common/math/fabs.asm \
1613 ../common/math/fabsf.asm \
1614 ../common/math/ldexp.asm \
1615 ../common/math/ldexpf.asm \
1616 ../common/math/llrint.asm \
1617 ../common/math/llrintf.asm \
1618 ../common/math/log.asm \
1619 ../common/math/logf.asm \
1620 ../common/math/lrint.asm \
1621 ../common/math/lrintf.asm \
1622 ../common/math/remainder.asm \
1623 ../common/math/remainderf.asm \
1624 ../common/math/rint.asm \
1625 ../common/math/rintf.asm \
1626 ../common/math/sin.asm \
1627 ../common/math/sinf.asm \
1628 ../common/math/sqrt.asm \
1629 ../common/math/sqrtf.asm \
1630 ../common/math/tan.asm \
1631 ../common/math/tanf.asm \
1632
1633#endif
1634
1635 return RTTestSummaryAndDestroy(g_hTest);
1636}
1637
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