diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-04-05 23:30:42 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-04-05 23:30:42 +0000 |
commit | 93c73ebcbd73f5436d13ffc41f49a86fc062deb8 (patch) | |
tree | 10bf9fb3a1314fc8a1c3b963b4550960718384ad /llgo/third_party/gofrontend/libgo/go/math/nextafter.go | |
parent | 7d39641c805bf3263ffb55a23ecf4bbfd37402c0 (diff) | |
download | bcm5719-llvm-93c73ebcbd73f5436d13ffc41f49a86fc062deb8.tar.gz bcm5719-llvm-93c73ebcbd73f5436d13ffc41f49a86fc062deb8.zip |
Roll gofrontend to a6e10414311a
This takes us to Go 1.4. Also includes a couple of changes to the test
suite, both in the runtime package:
- Disable TestSetPanicOnFault. We cannot support this scenario at all,
due to LLVM's lack of non-call exceptions.
- Tweak TestFinalizerType. This test only passes with two GC runs.
Differential Revision: http://reviews.llvm.org/D8828
llvm-svn: 234134
Diffstat (limited to 'llgo/third_party/gofrontend/libgo/go/math/nextafter.go')
-rw-r--r-- | llgo/third_party/gofrontend/libgo/go/math/nextafter.go | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/llgo/third_party/gofrontend/libgo/go/math/nextafter.go b/llgo/third_party/gofrontend/libgo/go/math/nextafter.go index 7c4b5bcdfef..bbb139986aa 100644 --- a/llgo/third_party/gofrontend/libgo/go/math/nextafter.go +++ b/llgo/third_party/gofrontend/libgo/go/math/nextafter.go @@ -4,12 +4,32 @@ package math -// Nextafter returns the next representable value after x towards y. -// If x == y, then x is returned. -// -// Special cases are: -// Nextafter(NaN, y) = NaN -// Nextafter(x, NaN) = NaN +// Nextafter32 returns the next representable float32 value after x towards y. +// Special cases: +// Nextafter32(x, x) = x +// Nextafter32(NaN, y) = NaN +// Nextafter32(x, NaN) = NaN +func Nextafter32(x, y float32) (r float32) { + switch { + case IsNaN(float64(x)) || IsNaN(float64(y)): // special case + r = float32(NaN()) + case x == y: + r = x + case x == 0: + r = float32(Copysign(float64(Float32frombits(1)), float64(y))) + case (y > x) == (x > 0): + r = Float32frombits(Float32bits(x) + 1) + default: + r = Float32frombits(Float32bits(x) - 1) + } + return +} + +// Nextafter returns the next representable float64 value after x towards y. +// Special cases: +// Nextafter64(x, x) = x +// Nextafter64(NaN, y) = NaN +// Nextafter64(x, NaN) = NaN func Nextafter(x, y float64) (r float64) { switch { case IsNaN(x) || IsNaN(y): // special case |