當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


GO Remainder用法及代碼示例

GO語言"math"包中"Remainder"函數的用法及代碼示例。

用法:

func Remainder(x, y float64) float64

Remainder 返回 x/y 的 IEEE 754 浮點餘數。

特殊情況是:

Remainder(±Inf, y) = NaN
Remainder(NaN, y) = NaN
Remainder(x, 0) = NaN
Remainder(x, ±Inf) = x
Remainder(x, NaN) = NaN

例子:

package main

import (
    "fmt"
    "math"
)

func main() {
    fmt.Printf("%.1f", math.Remainder(100, 30))
}

輸出:

10.0

相關用法


注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Remainder。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。