diff options
| author | Bruce Evans <bde@FreeBSD.org> | 1997-02-20 12:37:49 +0000 |
|---|---|---|
| committer | Bruce Evans <bde@FreeBSD.org> | 1997-02-20 12:37:49 +0000 |
| commit | 487ddb8fa4d3479e4367ed1d51eaa05af1a4fe6e (patch) | |
| tree | fdffc89d06b18a6465de3e1b9e67ae8a69046ecc /lib/msun/i387 | |
| parent | d5e4d7e154a19f571a359beb90f2678ee12d77e6 (diff) | |
Notes
Diffstat (limited to 'lib/msun/i387')
| -rw-r--r-- | lib/msun/i387/e_acos.S | 18 | ||||
| -rw-r--r-- | lib/msun/i387/e_asin.S | 16 |
2 files changed, 23 insertions, 11 deletions
diff --git a/lib/msun/i387/e_acos.S b/lib/msun/i387/e_acos.S index 84cb54273d56..774c65918967 100644 --- a/lib/msun/i387/e_acos.S +++ b/lib/msun/i387/e_acos.S @@ -37,14 +37,20 @@ RCSID("$FreeBSD$") -/* acos = atan (sqrt(1 - x^2) / x) */ +/* + * acos(x) = atan2(sqrt(1 - x^2, x). + * Actually evaluate (1 - x^2) as (1 - x) * (1 + x) to avoid loss of + * precision when |x| is nearly 1. + */ ENTRY(__ieee754_acos) fldl 4(%esp) /* x */ - fst %st(1) - fmul %st(0) /* x^2 */ - fld1 - fsubp /* 1 - x^2 */ - fsqrt /* sqrt (1 - x^2) */ + fld1 + fld %st(0) + fsub %st(2) /* 1 - x */ + fxch %st(1) + fadd %st(2) /* 1 + x */ + fmulp %st(1) /* (1 - x) * (1 + x) */ + fsqrt fxch %st(1) fpatan ret diff --git a/lib/msun/i387/e_asin.S b/lib/msun/i387/e_asin.S index 5b2a1bdaeb3f..de031cf9f4bc 100644 --- a/lib/msun/i387/e_asin.S +++ b/lib/msun/i387/e_asin.S @@ -37,13 +37,19 @@ RCSID("$FreeBSD$") -/* asin = atan (x / sqrt(1 - x^2)) */ +/* + * asin(x) = atan2(x, sqrt(1 - x^2). + * Actually evaluate (1 - x^2) as (1 - x) * (1 + x) to avoid loss of + * precision when |x| is nearly 1. + */ ENTRY(__ieee754_asin) fldl 4(%esp) /* x */ - fst %st(1) - fmul %st(0) /* x^2 */ fld1 - fsubp /* 1 - x^2 */ - fsqrt /* sqrt (1 - x^2) */ + fld %st(0) + fsub %st(2) /* 1 - x */ + fxch %st(1) + fadd %st(2) /* 1 + x */ + fmulp %st(1) /* (1 - x) * (1 + x) */ + fsqrt fpatan ret |
