Standard library / math
math.Modf()
Splits a float into integer and fractional parts, both with the input sign. Expected stdout: '-2 -0.5\n'.
Formal Syntax & Structure
go syntaxgo
func Modf(f float64) (int float64, frac float64)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| f | float64 | Input floating-point value. |
Return Value
(int float64, frac float64)
Splits a float into integer and fractional parts, both with the input sign.
Working Example
Example Snippetgo
package main
import ( "fmt" "math")
func main() { i, f := math.Modf(-2.5) fmt.Println(i, f)}