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