this repo has no description
1
2/*
3 * erf.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
14double erf( double x )
15{
16 union{ double d; uint64_t u;} u = { x };
17
18 uint64_t sign = u.u & 0x8000000000000000ULL;
19
20 //Inf, NaN, 0
21 if( (u.u & 0x7fffffffffffffffULL) - 1ULL >= 0x7ff0000000000000ULL - 1ULL )
22 {
23 if( 0.0 == x )
24 return x;
25
26 if( x != x )
27 return x + x;
28
29 u.u = 0x3ff0000000000000ULL | sign;
30 return u.d;
31 }
32
33 u.d = ErrFunApprox( x, 1.0, 0 );
34 u.u ^= sign;
35 return u.d;
36}