Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
unsafe.go42 linesDownload Raw Back to math
1// Copyright 2009 The Go Authors. All rights reserved.2// Use of this source code is governed by a BSD-style3// license that can be found in the LICENSE file.4 5package math6 7import "unsafe"8 9// Despite being an exported symbol,10// Float32bits is linknamed by widely used packages.11// Notable members of the hall of shame include:12//   - gitee.com/quant1x/num13//14// Do not remove or change the type signature.15// See go.dev/issue/67401.16//17// Note that this comment is not part of the doc comment.18//19//go:linkname Float32bits20 21// Float32bits returns the IEEE 754 binary representation of f,22// with the sign bit of f and the result in the same bit position.23// Float32bits(Float32frombits(x)) == x.24func Float32bits(f float32) uint32 { return *(*uint32)(unsafe.Pointer(&f)) }25 26// Float32frombits returns the floating-point number corresponding27// to the IEEE 754 binary representation b, with the sign bit of b28// and the result in the same bit position.29// Float32frombits(Float32bits(x)) == x.30func Float32frombits(b uint32) float32 { return *(*float32)(unsafe.Pointer(&b)) }31 32// Float64bits returns the IEEE 754 binary representation of f,33// with the sign bit of f and the result in the same bit position,34// and Float64bits(Float64frombits(x)) == x.35func Float64bits(f float64) uint64 { return *(*uint64)(unsafe.Pointer(&f)) }36 37// Float64frombits returns the floating-point number corresponding38// to the IEEE 754 binary representation b, with the sign bit of b39// and the result in the same bit position.40// Float64frombits(Float64bits(x)) == x.41func Float64frombits(b uint64) float64 { return *(*float64)(unsafe.Pointer(&b)) }42 
codekingpro/portable-devtools · Team Ai