// Copyright 2010 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 runtime// inf2one returns a signed 1 if f is an infinity and a signed 0 otherwise.// The sign of the result is the sign of f.func inf2one( float64) float64 { := 0.0ifisInf() { = 1.0 }returncopysign(, )}func complex128div( complex128, complex128) complex128 {var , float64// complex(e, f) = n/m// Algorithm for robust complex division as described in // Robert L. Smith: Algorithm 116: Complex division. Commun. ACM 5(8): 435 (1962).ifabs(real()) >= abs(imag()) { := imag() / real() := real() + *imag() = (real() + imag()*) / = (imag() - real()*) / } else { := real() / imag() := imag() + *real() = (real()* + imag()) / = (imag()* - real()) / }ifisNaN() && isNaN() {// Correct final result to infinities and zeros if applicable. // Matches C99: ISO/IEC 9899:1999 - G.5.1 Multiplicative operators. , := real(), imag() , := real(), imag()switch {case == 0 && (!isNaN() || !isNaN()): = copysign(inf, ) * = copysign(inf, ) * case (isInf() || isInf()) && isFinite() && isFinite(): = inf2one() = inf2one() = inf * (* + *) = inf * (* - *)case (isInf() || isInf()) && isFinite() && isFinite(): = inf2one() = inf2one() = 0 * (* + *) = 0 * (* - *) } }returncomplex(, )}
The pages are generated with Goldsv0.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.