| 574 | } |
| 575 | |
| 576 | func (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. |
| 603 | func (v Value) CanComplex() bool { |