---
name: "bttosbt"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/bttosbt"
---

# bttosbt(9)

Q32.32 fixed point representation of time

## NAME

**sbintime\_t**, **sbintime\_getsec**, **bttosbt**, **sbttobt**, **sbttons**, **nstosbt**, **sbttous**, **ustosbt**, **sbttoms**, **mstosbt**, **sbttots**, **tstosbt**, **sbttotv**, **tvtosbt** – Q32.32 fixed point representation of time

## SYNOPSIS

**#include \<sys/types.h\>**

**#include \<sys/time.h\>**

*typedef* *\_\_int64\_t* *\_\_sbintime\_t*; *typedef* *\_\_sbintime\_t* *sbintime\_t*;

**#define SBT\_1S ((sbintime\_t)1 \<\< 32)**

**#define SBT\_1M (SBT\_1S \* 60)**

**#define SBT\_1MS (SBT\_1S / 1000)**

**#define SBT\_1US (SBT\_1S / 1000000)**

**#define SBT\_1NS (SBT\_1S / 1000000000)**

*int*\

**sbintime\_getsec**(*sbintime\_t sbt*);

*sbintime\_t*\

**bttosbt**(*const struct bintime bt*);

*struct* *bintime*\

**sbttobt**(*sbintime\_t sbt*);

*int64\_t*\

**sbttons**(*sbintime\_t sbt*);

*sbintime\_t*\

**nstosbt**(*int64\_t ns*);

*int64\_t*\

**sbttous**(*sbintime\_t sbt*);

*sbintime\_t*\

**ustosbt**(*int64\_t us*);

*int64\_t*\

**sbttoms**(*sbintime\_t sbt*);

*sbintime\_t*\

**mstosbt**(*int64\_t ms*);

*struct* *timespec*\

**sbttots**(*sbintime\_t sbt*);

*sbintime\_t*\

**tstosbt**(*struct timespec ts*);

*struct* *timeval*\

**sbttotv**(*sbintime\_t sbt*);

*sbintime\_t*\

**tvtosbt**(*struct timeval tv*);

## DESCRIPTION

The *sbintime\_t* type is a Q32.32 fixed point representation of time. The high 32-bit integral bits specify the number of seconds, and the low 32-bit fractional bits specify the sub-second portion. Since the lower 32 bits are counting with a base unit of 1/2^32 seconds, ‘(sbintime\_t)0x1’ is just under 250 picoseconds.

All of the conversion functions are designed to do the conversion without large truncation errors that are possible with naive math.

- **sbintime\_getsec**(*sbt*)

  Return the whole number of seconds from a *sbintime\_t* specified by the *sbt* argument.

- **bttosbt**(*bt*)

  Convert a *struct* *bintime* specified by the *bt* argument to a *sbintime\_t*.

- **sbttobt**(*sbt*)

  Convert a *sbintime\_t* specified by the *sbt* argument to a *struct bintime*.

- **sbttons**(*sbt*)

  Convert a *sbintime\_t* specified by the *sbt* argument to the number of nanoseconds.

- **nstosbt**(*ns*)

  Convert the number of nanoseconds specified by the *ns* argument to a *sbintime\_t*.

- **sbttous**(*sbt*)

  Convert a *sbintime\_t* specified by the *sbt* argument to the number of microseconds.

- **ustosbt**(*us*)

  Convert the number of microseconds specified by the *us* argument to a *sbintime\_t*.

- **sbttoms**(*sbt*)

  Convert a *sbintime\_t* specified by the *sbt* argument to the number of milliseconds.

- **mstosbt**(*ms*)

  Convert the number of milliseconds specified by the *ms* argument to a *sbintime\_t*.

- **sbttots**(*sbt*)

  Convert a *sbintime\_t* specified by the *sbt* argument to a *struct timespec*.

- **tstosbt**(*ts*)

  Convert a *struct timespec* specified by the *ts* argument to a *sbintime\_t*.

- **sbttotv**(*sbt*)

  Convert a *sbintime\_t* specified by the *sbt* argument to a *struct timeval*.

- **tvtosbt**(*tv*)

  Convert a *struct timeval* specified by the *tv* argument to a *sbintime\_t*.

## SEE ALSO

[bintime(9)](/bintime/9.md), [callout(9)](/callout/9.md), [tvtohz(9)](/tvtohz/9.md)

## HISTORY

The **sbintime\_t** type and most of the helper functions first appeared in FreeBSD 10.0. The Xstosbt functions first appeared in FreeBSD 12.0.

## AUTHORS

This manual page was written by Ka Ho Ng ⟨*khng@FreeBSD.org*⟩.
