MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / FloatArrayAsBytes

Function FloatArrayAsBytes

types/value.go:38–47  ·  view source on GitHub ↗

FloatArrayAsBytes(v) will create a byte array encoding v using LittleEndian format. This is sort of the inverse of BytesAsFloatArray, but note that we can always be successful converting to bytes, but the inverse is not feasible.

(v []float32)

Source from the content-addressed store, hash-verified

36// of BytesAsFloatArray, but note that we can always be successful
37// converting to bytes, but the inverse is not feasible.
38func FloatArrayAsBytes(v []float32) []byte {
39 retVal := make([]byte, 4*len(v))
40 offset := retVal
41 for i := range v {
42 bits := math.Float32bits(v[i])
43 binary.LittleEndian.PutUint32(offset, bits)
44 offset = offset[4:]
45 }
46 return retVal
47}
48
49func FloatArrayAsString(v []float32) string {
50 var sb strings.Builder

Callers 4

handleBasicTypeFunction · 0.92
bsFunction · 0.85
MarshalFunction · 0.85

Calls

no outgoing calls

Tested by 2

bsFunction · 0.68