1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // Logb returns the binary exponent of x.
14 func Logb(x float64) float64 {
24 return float64(ilogb(x))
27 // Ilogb returns the binary exponent of x as an integer.
31 // Ilogb(±Inf) = MaxInt32
32 // Ilogb(0) = MinInt32
33 // Ilogb(NaN) = MaxInt32
34 func Ilogb(x float64) int {
47 // ilogb returns the binary exponent of x. It assumes x is finite and
49 func ilogb(x float64) int {
50 x, exp := normalize(x)
51 return int((Float64bits(x)>>shift)&mask) - bias + exp