MCPcopy
hub / github.com/tinygo-org/tinygo / Float

Method Float

src/internal/reflectlite/value.go:576–600  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

574}
575
576func (v Value) Float() float64 {
577 switch v.Kind() {
578 case Float32:
579 if v.isIndirect() || unsafe.Sizeof(float32(0)) > unsafe.Sizeof(uintptr(0)) {
580 // The float is stored as an external value on systems with 16-bit
581 // pointers.
582 return float64(*(*float32)(v.value))
583 } else {
584 // The float is directly stored in the interface value on systems
585 // with 32-bit and 64-bit pointers.
586 return float64(*(*float32)(unsafe.Pointer(&v.value)))
587 }
588 case Float64:
589 if v.isIndirect() || unsafe.Sizeof(float64(0)) > unsafe.Sizeof(uintptr(0)) {
590 // For systems with 16-bit and 32-bit pointers.
591 return *(*float64)(v.value)
592 } else {
593 // The float is directly stored in the interface value on systems
594 // with 64-bit pointers.
595 return *(*float64)(unsafe.Pointer(&v.value))
596 }
597 default:
598 panic(&ValueError{Method: "Float", Kind: v.Kind()})
599 }
600}
601
602// CanComplex reports whether Complex can be used without panicking.
603func (v Value) CanComplex() bool {

Callers 10

IsZeroMethod · 0.95
EqualMethod · 0.95
Float32Method · 0.95
mainFunction · 0.80
showValueFunction · 0.80
valueToStringFunction · 0.80
cvtFloatIntFunction · 0.80
cvtFloatUintFunction · 0.80
cvtFloatFunction · 0.80
reflectValueEqualFunction · 0.80

Implementers 12

refMapcgo/sync.go
ADCsrc/machine/machine.go
pwmGroupsrc/machine/machine_rp2_pwm.go
RingBuffersrc/machine/buffer.go
RingBuffersrc/machine/usb/adc/midi/buffer.go
RingBuffersrc/machine/usb/hid/buffer.go
Register8src/runtime/volatile/register.go
Register16src/runtime/volatile/register.go
Register32src/runtime/volatile/register.go
Register64src/runtime/volatile/register.go
BitRegistersrc/runtime/volatile/bitband_nxpmk66f1
Poolsrc/sync/pool.go

Calls 4

KindMethod · 0.95
isIndirectMethod · 0.95
SizeofMethod · 0.80
PointerMethod · 0.80

Tested by 1

valueToStringFunction · 0.64