// 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
}