1
0
mirror of https://github.com/golang/go synced 2024-11-19 12:34:47 -07:00

math: Expm1 returns -1 with large negative argument.

Fixes #11442

Change-Id: I2053fe752c6a122924d28565f1338f73e00ed417
Reviewed-on: https://go-review.googlesource.com/11791
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Charlie Dorian 2015-06-30 20:14:30 -04:00 committed by Ian Lance Taylor
parent 1082e2390e
commit 8b221092b9
2 changed files with 8 additions and 4 deletions

View File

@ -946,16 +946,20 @@ var expSC = []float64{
var vfexpm1SC = []float64{
Inf(-1),
-710,
Copysign(0, -1),
0,
710,
Inf(1),
NaN(),
}
var expm1SC = []float64{
-1,
-1,
Copysign(0, -1),
0,
Inf(1),
Inf(1),
NaN(),
}

View File

@ -158,11 +158,11 @@ func expm1(x float64) float64 {
// filter out huge argument
if absx >= Ln2X56 { // if |x| >= 56 * ln2
if absx >= Othreshold { // if |x| >= 709.78...
return Inf(1) // overflow
}
if sign {
return -1 // x < -56*ln2, return -1.0
return -1 // x < -56*ln2, return -1
}
if absx >= Othreshold { // if |x| >= 709.78...
return Inf(1)
}
}