Blame sysdeps/ieee754/flt-32/s_ceilf.c
|
Packit Service |
82fcde |
/* s_ceilf.c -- float version of s_ceil.c.
|
|
Packit Service |
82fcde |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/*
|
|
Packit Service |
82fcde |
* ====================================================
|
|
Packit Service |
82fcde |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
Packit Service |
82fcde |
*
|
|
Packit Service |
82fcde |
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
Packit Service |
82fcde |
* Permission to use, copy, modify, and distribute this
|
|
Packit Service |
82fcde |
* software is freely granted, provided that this notice
|
|
Packit Service |
82fcde |
* is preserved.
|
|
Packit Service |
82fcde |
* ====================================================
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <math.h>
|
|
Packit Service |
82fcde |
#include <math_private.h>
|
|
Packit Service |
82fcde |
#include <libm-alias-float.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
float
|
|
Packit Service |
82fcde |
__ceilf(float x)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
int32_t i0,j0;
|
|
Packit Service |
82fcde |
uint32_t i;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
GET_FLOAT_WORD(i0,x);
|
|
Packit Service |
82fcde |
j0 = ((i0>>23)&0xff)-0x7f;
|
|
Packit Service |
82fcde |
if(j0<23) {
|
|
Packit Service |
82fcde |
if(j0<0) {
|
|
Packit Service |
82fcde |
/* return 0*sign(x) if |x|<1 */
|
|
Packit Service |
82fcde |
if(i0<0) {i0=0x80000000;}
|
|
Packit Service |
82fcde |
else if(i0!=0) { i0=0x3f800000;}
|
|
Packit Service |
82fcde |
} else {
|
|
Packit Service |
82fcde |
i = (0x007fffff)>>j0;
|
|
Packit Service |
82fcde |
if((i0&i)==0) return x; /* x is integral */
|
|
Packit Service |
82fcde |
if(i0>0) i0 += (0x00800000)>>j0;
|
|
Packit Service |
82fcde |
i0 &= (~i);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
} else {
|
|
Packit Service |
82fcde |
if(__builtin_expect(j0==0x80, 0)) return x+x; /* inf or NaN */
|
|
Packit Service |
82fcde |
else return x; /* x is integral */
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
SET_FLOAT_WORD(x,i0);
|
|
Packit Service |
82fcde |
return x;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
#ifndef __ceilf
|
|
Packit Service |
82fcde |
libm_alias_float (__ceil, ceil)
|
|
Packit Service |
82fcde |
#endif
|