Debian Codegraph @

src/internal/strconv/deps.go

raw
1 // Copyright 2025 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package strconv
6
7 import "unsafe"
8
9 // Implementations to avoid importing other dependencies.
10
11 // package math
12
13 func float64frombits(b uint64) float64 { return *(*float64)(unsafe.Pointer(&b)) }
14 func float32frombits(b uint32) float32 { return *(*float32)(unsafe.Pointer(&b)) }
15 func float64bits(f float64) uint64 { return *(*uint64)(unsafe.Pointer(&f)) }
16 func float32bits(f float32) uint32 { return *(*uint32)(unsafe.Pointer(&f)) }
17
18 func inf(sign int) float64 {
19 var v uint64
20 if sign >= 0 {
21 v = 0x7FF0000000000000
22 } else {
23 v = 0xFFF0000000000000
24 }
25 return float64frombits(v)
26 }
27
28 func isNaN(f float64) (is bool) { return f != f }
29
30 func nan() float64 { return float64frombits(0x7FF8000000000001) }