this repo has no description
1
2/*
3 * erff.c
4 *
5 * by Ian Ollmann
6 *
7 * Copyright (c) 2007, Apple Inc. All Rights Reserved.
8 */
9
10#include <math.h>
11#include <stdint.h>
12#include "erf.h"
13
14float erff( float x )
15{
16 union{ float d; uint32_t u;} u = { x };
17
18 uint32_t sign = u.u & 0x80000000U;
19
20 //Inf, NaN, 0
21 if( (u.u & 0x7fffffffU) - 1U >= 0x7f800000U - 1U )
22 {
23 if( 0.0f == x )
24 return x;
25
26 if( x != x )
27 return x + x;
28
29 u.u = 0x3f800000U | sign;
30 return u.d;
31 }
32
33 u.d = (float) ErrFunApprox( (double) x, 1.0, 0 );
34 u.u ^= sign;
35 return u.d;
36}