MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / floatToNanos

Function floatToNanos

pkg/sql/sem/tree/interval.go:666–668  ·  view source on GitHub ↗

floatToNanos converts a fractional number representing nanoseconds to the number of integer nanoseconds. For example: ".354874219" to "354874219" or ".123" to "123000000". This function takes care to round correctly when a naive conversion would incorrectly truncate due to floating point inaccuracie

(f float64)

Source from the content-addressed store, hash-verified

664// https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/adt/timestamp.c;h=449164ae7e5b00f6580771017888d4922685a73c;hb=HEAD#l1511
665// https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/port/rint.c;h=d59d9ab774307b7db2f7cb2347815a30da563fc5;hb=HEAD
666func floatToNanos(f float64) int64 {
667 return int64(math.Round(f * float64(time.Second.Nanoseconds())))
668}

Callers 1

parseShortDurationMethod · 0.85

Calls 1

RoundMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…