Skip to content

Commit e01231b

Browse files
committed
[CRT:MATH] Implement _finite, _finitef
1 parent 5002868 commit e01231b

File tree

5 files changed

+41
-17
lines changed

5 files changed

+41
-17
lines changed

dll/win32/ucrtbase/ucrtbase.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@
371371
@ cdecl _findnext64(long ptr)
372372
@ cdecl _findnext64i32(long ptr)
373373
@ cdecl _finite(double)
374-
@ cdecl -stub -arch=!i386 _finitef(float)
374+
@ cdecl -arch=!i386 _finitef(float)
375375
@ cdecl _flushall()
376376
@ cdecl _fpclass(double)
377377
@ cdecl -stub -arch=!i386 _fpclassf(float)

sdk/lib/crt/float/isnan.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,3 @@ int CDECL _isnan(double __x)
3636
x.__x = &__x;
3737
return ( x.x->exponent == 0x7ff && ( x.x->mantissah != 0 || x.x->mantissal != 0 ));
3838
}
39-
40-
/*
41-
* @implemented
42-
*/
43-
int CDECL _finite(double __x)
44-
{
45-
union
46-
{
47-
double* __x;
48-
double_s* x;
49-
} x;
50-
51-
x.__x = &__x;
52-
53-
return ((x.x->exponent & 0x7ff) != 0x7ff);
54-
}

sdk/lib/crt/math/_finite.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* PROJECT: ReactOS CRT
3+
* LICENSE: MIT (https://spdx.org/licenses/MIT)
4+
* PURPOSE: Implementation of _finite.
5+
* COPYRIGHT: Copyright 2025 Timo Kreuzer <[email protected]>
6+
*/
7+
8+
#include <float.h>
9+
#include <stdint.h>
10+
11+
_Check_return_
12+
int
13+
__cdecl
14+
_finite(_In_ double _X)
15+
{
16+
union { double f; uint64_t ui64; } u = { _X };
17+
uint64_t exp = u.ui64 & 0x7FF0000000000000;
18+
return (exp != 0x7FF0000000000000);
19+
}

sdk/lib/crt/math/_finitef.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* PROJECT: ReactOS CRT
3+
* LICENSE: MIT (https://spdx.org/licenses/MIT)
4+
* PURPOSE: Implementation of _finitef.
5+
* COPYRIGHT: Copyright 2025 Timo Kreuzer <[email protected]>
6+
*/
7+
8+
#include <float.h>
9+
#include <stdint.h>
10+
11+
_Check_return_
12+
int
13+
__cdecl
14+
_finitef(_In_ float _X)
15+
{
16+
union { float f; uint32_t ui32; } u = { _X };
17+
uint32_t exp = u.ui32 & 0x7F800000;
18+
return (exp != 0x7F800000);
19+
}

sdk/lib/crt/math/math.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ list(APPEND LIBCNTPR_MATH_SOURCE
55
math/_chgsignf.c
66
math/_dsign.c
77
math/_fdsign.c
8+
math/_finite.c
9+
math/_finitef.c
810
math/_invoke_matherr.c
911
math/abs.c
1012
math/div.c

0 commit comments

Comments
 (0)