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

Function encodeFloat8

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

Source from the content-addressed store, hash-verified

433}
434
435func encodeFloat8(v interface{}) []byte {
436 buf := make([]byte, 8)
437 var f float64
438 switch val := v.(type) {
439 case float64:
440 f = val
441 case float32:
442 f = float64(val)
443 case int:
444 f = float64(val)
445 case int32:
446 f = float64(val)
447 case int64:
448 f = float64(val)
449 default:
450 return nil
451 }
452 binary.BigEndian.PutUint64(buf, math.Float64bits(f))
453 return buf
454}
455
456// PostgreSQL epoch is 2000-01-01, Unix epoch is 1970-01-01
457// Difference in days: 10957

Callers 2

TestEncodeFloat8Function · 0.85
encodeBinaryFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestEncodeFloat8Function · 0.68