ntdll: Copy ceil() implementation from msvcrt.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bb9e068bab
commit
fca34420f6
|
@ -146,10 +146,31 @@ double CDECL atan( double x )
|
|||
|
||||
/*********************************************************************
|
||||
* ceil (NTDLL.@)
|
||||
*
|
||||
* Based on musl: src/math/ceilf.c
|
||||
*/
|
||||
double CDECL ceil( double d )
|
||||
double CDECL ceil( double x )
|
||||
{
|
||||
return unix_funcs->ceil( d );
|
||||
union {double f; UINT64 i;} u = {x};
|
||||
int e = (u.i >> 52 & 0x7ff) - 0x3ff;
|
||||
UINT64 m;
|
||||
|
||||
if (e >= 52)
|
||||
return x;
|
||||
if (e >= 0) {
|
||||
m = 0x000fffffffffffffULL >> e;
|
||||
if ((u.i & m) == 0)
|
||||
return x;
|
||||
if (u.i >> 63 == 0)
|
||||
u.i += m;
|
||||
u.i &= ~m;
|
||||
} else {
|
||||
if (u.i >> 63)
|
||||
return -0.0;
|
||||
else if (u.i << 1)
|
||||
return 1.0;
|
||||
}
|
||||
return u.f;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
|
Loading…
Reference in New Issue