| // 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. |
| // Ldexp is the inverse of Frexp. |
| // It returns frac × 2**exp. |
| // Ldexp(±Inf, exp) = ±Inf |
| func Ldexp(frac float64, exp int) float64 |
| func ldexp(frac float64, exp int) float64 { |
| return frac // correctly return -0 |
| case IsInf(frac, 0) || IsNaN(frac): |
| frac, e := normalize(frac) |
| exp += int(x>>shift)&mask - bias |
| return Copysign(0, frac) // underflow |
| if exp > 1023 { // overflow |
| if exp < -1022 { // denormal |
| m = 1.0 / (1 << 52) // 2**-52 |
| x |= uint64(exp+bias) << shift |
| return m * Float64frombits(x) |