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(x) returns the binary exponent of x.
13 func Logb(x
float64) float64 {
23 return float64(ilogb(x
))
26 // Ilogb(x) returns the binary exponent of x as an integer.
29 // Ilogb(±Inf) = MaxInt32
30 // Ilogb(0) = MinInt32
31 // Ilogb(NaN) = MaxInt32
32 func Ilogb(x
float64) int {
45 // logb returns the binary exponent of x. It assumes x is finite and
47 func ilogb(x
float64) int {
48 x
, exp
:= normalize(x
)
49 return int((Float64bits(x
)>>shift
)&mask
) - bias
+ exp