MCPcopy Create free account
hub / github.com/PostHog/duckgres / encodeFloat4

Function encodeFloat4

server/types.go:414–433  ·  view source on GitHub ↗
(v interface{})

Source from the content-addressed store, hash-verified

412}
413
414func encodeFloat4(v interface{}) []byte {
415 buf := make([]byte, 4)
416 var f float32
417 switch val := v.(type) {
418 case float32:
419 f = val
420 case float64:
421 f = float32(val)
422 case int:
423 f = float32(val)
424 case int32:
425 f = float32(val)
426 case int64:
427 f = float32(val)
428 default:
429 return nil
430 }
431 binary.BigEndian.PutUint32(buf, math.Float32bits(f))
432 return buf
433}
434
435func encodeFloat8(v interface{}) []byte {
436 buf := make([]byte, 8)

Callers 2

TestEncodeFloat4Function · 0.85
encodeBinaryFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestEncodeFloat4Function · 0.68