Source File
frexp.go
Belonging Package
math
// Copyright 2009 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
// Frexp breaks f into a normalized fraction
// and an integral power of two.
// It returns frac and exp satisfying f == frac × 2**exp,
// with the absolute value of frac in the interval [½, 1).
//
// Special cases are:
//
// Frexp(±0) = ±0, 0
// Frexp(±Inf) = ±Inf, 0
// Frexp(NaN) = NaN, 0
func ( float64) ( float64, int) {
if haveArchFrexp {
return archFrexp()
}
return frexp()
}
func frexp( float64) ( float64, int) {
// special cases
switch {
case == 0:
return , 0 // correctly return -0
case IsInf(, 0) || IsNaN():
return , 0
}
, = normalize()
:= Float64bits()
+= int((>>shift)&mask) - bias + 1
&^= mask << shift
|= (-1 + bias) << shift
= Float64frombits()
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. |