1 // Copyright 2009 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 // Ldexp is the inverse of Frexp.
8 // It returns frac × 2**exp.
9 func Ldexp(frac
float64, exp
int) float64 {
10 // TODO(rsc): Remove manual inlining of IsNaN, IsInf
11 // when compiler does it for us
15 return frac
// correctly return -0
16 case frac
!= frac
: // IsNaN(frac):
19 x
:= Float64bits(frac
)
20 exp
+= int(x
>>shift
) & mask
24 if exp
>= mask
{ // overflow
31 x |
= uint64(exp
) << shift
32 return Float64frombits(x
)