BytesAsFloatArray(encoded) converts encoded into a []float32. If len(encoded) % 4 is not 0, it will ignore any trailing bytes, and simply convert 4 bytes at a time to generate the float64 entries. Current implementation assuming littleEndian encoding
(encoded []byte)
| 19 | // float64 entries. |
| 20 | // Current implementation assuming littleEndian encoding |
| 21 | func BytesAsFloatArray(encoded []byte) []float32 { |
| 22 | resultLen := len(encoded) / 4 |
| 23 | if resultLen == 0 { |
| 24 | return []float32{} |
| 25 | } |
| 26 | retVal := make([]float32, resultLen) |
| 27 | for i := range resultLen { |
| 28 | retVal[i] = *(*float32)(unsafe.Pointer(&encoded[0])) |
| 29 | encoded = encoded[4:] |
| 30 | } |
| 31 | return retVal |
| 32 | } |
| 33 | |
| 34 | // FloatArrayAsBytes(v) will create a byte array encoding |
| 35 | // v using LittleEndian format. This is sort of the inverse |
no outgoing calls