-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathdeps.go
More file actions
28 lines (21 loc) · 825 Bytes
/
deps.go
File metadata and controls
28 lines (21 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package strconv
import "unsafe"
// Implementations to avoid importing other dependencies.
// package math
func float64frombits(b uint64) float64 { return *(*float64)(unsafe.Pointer(&b)) }
func float32frombits(b uint32) float32 { return *(*float32)(unsafe.Pointer(&b)) }
func float64bits(f float64) uint64 { return *(*uint64)(unsafe.Pointer(&f)) }
func float32bits(f float32) uint32 { return *(*uint32)(unsafe.Pointer(&f)) }
func floatInf(sign int) float64 {
var v uint64
if sign >= 0 {
v = 0x7FF0000000000000
} else {
v = 0xFFF0000000000000
}
return float64frombits(v)
}
func floatNaN() float64 { return float64frombits(0x7FF8000000000001) }