Source file src/math/modf.go

     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.
     4  
     5  package math
     6  
     7  // Modf returns integer and fractional floating-point numbers
     8  // that sum to f. Both values have the same sign as f.
     9  //
    10  // Special cases are:
    11  //
    12  //	Modf(±Inf) = ±Inf, NaN
    13  //	Modf(NaN) = NaN, NaN
    14  func Modf(f float64) (integer float64, fractional float64) {
    15  	integer = Trunc(f)
    16  	fractional = Copysign(f-integer, f)
    17  	return
    18  }
    19  

View as plain text