Source File
ldexp.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
// Ldexp is the inverse of Frexp.
// It returns frac × 2**exp.
//
// Special cases are:
//
// Ldexp(±0, exp) = ±0
// Ldexp(±Inf, exp) = ±Inf
// Ldexp(NaN, exp) = NaN
func ( float64, int) float64 {
if haveArchLdexp {
return archLdexp(, )
}
return ldexp(, )
}
func ( float64, int) float64 {
// special cases
switch {
case == 0:
return // correctly return -0
case IsInf(, 0) || IsNaN():
return
}
, := normalize()
+=
:= Float64bits()
+= int(>>shift)&mask - bias
if < -1075 {
return Copysign(0, ) // underflow
}
if > 1023 { // overflow
if < 0 {
return Inf(-1)
}
return Inf(1)
}
var float64 = 1
if < -1022 { // denormal
+= 53
= 1.0 / (1 << 53) // 2**-53
}
&^= mask << shift
|= uint64(+bias) << shift
return * Float64frombits()
}
The pages are generated with Golds v0.6.7. (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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |