Blame sysdeps/ieee754/flt-32/s_rintf.c

Packit 6c4009
/* s_rintf.c -- float version of s_rint.c.
Packit 6c4009
 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * ====================================================
Packit 6c4009
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
Packit 6c4009
 *
Packit 6c4009
 * Developed at SunPro, a Sun Microsystems, Inc. business.
Packit 6c4009
 * Permission to use, copy, modify, and distribute this
Packit 6c4009
 * software is freely granted, provided that this notice
Packit 6c4009
 * is preserved.
Packit 6c4009
 * ====================================================
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#include <math.h>
Packit 6c4009
#include <math_private.h>
Packit 6c4009
#include <libm-alias-float.h>
Packit Service 4880ca
#include <math-use-builtins.h>
Packit 6c4009
Packit 6c4009
float
Packit Service 3b0880
__rintf(float x)
Packit 6c4009
{
Packit Service 4880ca
#if USE_RINTF_BUILTIN
Packit Service 4880ca
  return __builtin_rintf (x);
Packit Service 4880ca
#else
Packit Service 4880ca
  /* Use generic implementation.  */
Packit Service 4880ca
  static const float
Packit Service 4880ca
    TWO23[2] = {
Packit Service 4880ca
		8.3886080000e+06, /* 0x4b000000 */
Packit Service 4880ca
		-8.3886080000e+06, /* 0xcb000000 */
Packit Service 4880ca
  };
Packit Service 3b0880
	int32_t i0,j0,sx;
Packit Service 3b0880
	float w,t;
Packit Service 3b0880
	GET_FLOAT_WORD(i0,x);
Packit Service 3b0880
	sx = (i0>>31)&1;
Packit Service 3b0880
	j0 = ((i0>>23)&0xff)-0x7f;
Packit Service 3b0880
	if(j0<23) {
Packit Service 3b0880
	    if(j0<0) {
Packit Service 3b0880
		w = TWO23[sx]+x;
Packit Service 3b0880
		t =  w-TWO23[sx];
Packit Service 3b0880
		GET_FLOAT_WORD(i0,t);
Packit Service 3b0880
		SET_FLOAT_WORD(t,(i0&0x7fffffff)|(sx<<31));
Packit Service 3b0880
		return t;
Packit Service 3b0880
	    }
Packit Service 3b0880
	} else {
Packit Service 3b0880
	    if(j0==0x80) return x+x;	/* inf or NaN */
Packit Service 3b0880
	    else return x;		/* x is integral */
Packit 6c4009
	}
Packit Service 3b0880
	w = TWO23[sx]+x;
Packit Service 3b0880
	return w-TWO23[sx];
Packit Service 4880ca
#endif /* ! USE_RINTF_BUILTIN  */
Packit 6c4009
}
Packit 6c4009
#ifndef __rintf
Packit 6c4009
libm_alias_float (__rint, rint)
Packit 6c4009
#endif