go源碼閱讀筆記(math.4)

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。

go源碼閱讀筆記(math.4)

參考godoc API

API列表

func NaN() float64

函數返回一個IEEE 754“這不是一個數字”值。

func IsNaN(f float64) (is bool)

判斷f是否是NaN值

func Inf(sign int) float64

如果sign>=0返回正無窮大,否則返回負無窮大

func IsInf(f float64, sign int) bool

判斷其是否是無窮大數

func Float32bits(f float32) uint32

函數返回浮點數f的IEEE 754格式二進位表示的值對應的4位元組不帶正負號的整數(每位值不變)。主要是用於位元運算之類的,轉換成不帶正負號的整數,這樣不會使用浮點運算器,速度快

func Float32frombits(b uint32) float32

將4位元組不帶正負號的整數每位不變,轉換成float32值,與Float32bits對應

func Float64bits(f float64) uint64

與Float32bits類似

func Float64frombits(b uint64) float64

與Float32frombits類似

func Signbit(x float64) bool

func Signbit(x float64) bool {    return Float64bits(x)&(1<<63) != 0}

如果x是負數或者負0(一種0的表示方式),則返回true

func Copysign(x, y float64) float64

// Copysign returns a value with the magnitude// of x and the sign of y.func Copysign(x, y float64) float64 {    const sign = 1 << 63    return Float64frombits(Float64bits(x)&^sign | Float64bits(y)&sign)}

返回擁有x的量值(絕對值)和y的標誌位(加號或減號)的浮點數。

func Ceil(x float64) float64

返回不小於x的最小整數(的浮點值)

特殊值情境

Ceil(±0) = ±0Ceil(±Inf) = ±InfCeil(NaN) = NaN

func Floor(x float64) float64

返回不大於x的最小整數(的浮點值)

特殊值情境

Floor(±0) = ±0Floor(±Inf) = ±InfFloor(NaN) = NaN

func Trunc(x float64) float64

返回x的整數部分(浮點數類型)

特殊值情境

Trunc(±0) = ±0Trunc(±Inf) = ±InfTrunc(NaN) = NaN

func Modf(f float64) (int float64, frac float64)

返回f的整數部分和小數部分,結果的加號或減號和都x相同,比如1.1返回1.0和0.1,-1.1返回-1.0和-0.1

特殊值情境

Modf(±Inf) = ±Inf, NaNModf(NaN) = NaN, NaN

今天太晚了,後面的下次再補。

func Nextafter(x, y float64) (r float64)

func Abs(x float64) float64
func Max(x, y float64) float64
func Min(x, y float64) float64
func Dim(x, y float64) float64
func Mod(x, y float64) float64
func Remainder(x, y float64) float64
func Sqrt(x float64) float64
func Cbrt(x float64) float64
func Hypot(p, q float64) float64
func Sin(x float64) float64
func Cos(x float64) float64
func Tan(x float64) float64
func Sincos(x float64) (sin, cos float64)
func Asin(x float64) float64
func Acos(x float64) float64
func Atan(x float64) float64
func Atan2(y, x float64) float64
func Sinh(x float64) float64
func Cosh(x float64) float64
func Tanh(x float64) float64
func Asinh(x float64) float64
func Acosh(x float64) float64
func Atanh(x float64) float64
func Log(x float64) float64
func Log1p(x float64) float64
func Log2(x float64) float64
func Log10(x float64) float64
func Logb(x float64) float64
func Ilogb(x float64) int
func Frexp(f float64) (frac float64, exp int)
func Ldexp(frac float64, exp int) float64
func Exp(x float64) float64
func Expm1(x float64) float64
func Exp2(x float64) float64
func Pow(x, y float64) float64
func Pow10(e int) float64
func Gamma(x float64) float64
func Lgamma(x float64) (lgamma float64, sign int)
func Erf(x float64) float64
func Erfc(x float64) float64
func J0(x float64) float64
func J1(x float64) float64
func Jn(n int, x float64) float64
func Y0(x float64) float64
func Y1(x float64) float64
func Yn(n int, x float64) float64

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.