Source File
nextafter.go
Belonging Package
math
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package math
// Nextafter32 returns the next representable float32 value after x towards y.
//
// Special cases are:
//
// Nextafter32(x, x) = x
// Nextafter32(NaN, y) = NaN
// Nextafter32(x, NaN) = NaN
func (, float32) ( float32) {
switch {
case IsNaN(float64()) || IsNaN(float64()): // special case
= float32(NaN())
case == :
=
case == 0:
= float32(Copysign(float64(Float32frombits(1)), float64()))
case ( > ) == ( > 0):
= Float32frombits(Float32bits() + 1)
default:
= Float32frombits(Float32bits() - 1)
}
return
}
// Nextafter returns the next representable float64 value after x towards y.
//
// Special cases are:
//
// Nextafter(x, x) = x
// Nextafter(NaN, y) = NaN
// Nextafter(x, NaN) = NaN
func (, float64) ( float64) {
switch {
case IsNaN() || IsNaN(): // special case
= NaN()
case == :
=
case == 0:
= Copysign(Float64frombits(1), )
case ( > ) == ( > 0):
= Float64frombits(Float64bits() + 1)
default:
= Float64frombits(Float64bits() - 1)
}
return
}
The pages are generated with Golds v0.7.0-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |