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) = NaNfunc (, 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) = NaNfunc (, 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}