mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Ported cosf(), coshf(), sinf(), sinhf(), tanf(), tanhf()
and hypotf() for C99. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14964 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: math_sinf.c,v 1.1 2005-05-29 11:19:01 obarthel Exp $
|
||||
* $Id: math_sinf.c,v 1.2 2005-05-30 08:10:38 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -29,6 +29,18 @@
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* PowerPC math library based in part on work by Sun Microsystems
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
*
|
||||
*
|
||||
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
|
||||
*/
|
||||
|
||||
#ifndef _MATH_HEADERS_H
|
||||
@@ -44,8 +56,29 @@
|
||||
float
|
||||
sinf(float x)
|
||||
{
|
||||
/* ZZZ unimplemented */
|
||||
return(0);
|
||||
float y[2],z=0.0;
|
||||
LONG n,ix;
|
||||
|
||||
GET_FLOAT_WORD(ix,x);
|
||||
|
||||
/* |x| ~< pi/4 */
|
||||
ix &= 0x7fffffff;
|
||||
if(ix <= 0x3f490fd8) return __kernel_sinf(x,z,0);
|
||||
|
||||
/* sin(Inf or NaN) is NaN */
|
||||
else if (ix>=0x7f800000) return x-x;
|
||||
|
||||
/* argument reduction needed */
|
||||
else {
|
||||
n = __rem_pio2f(x,y);
|
||||
switch(n&3) {
|
||||
case 0: return __kernel_sinf(y[0],y[1],1);
|
||||
case 1: return __kernel_cosf(y[0],y[1]);
|
||||
case 2: return -__kernel_sinf(y[0],y[1],1);
|
||||
default:
|
||||
return -__kernel_cosf(y[0],y[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user