Rerun C++ SDK
Loading...
Searching...
No Matches
half.hpp
1#pragma once
2
3#include <cstdint>
4
5// Declared here rather than by including `c/rerun.h`: `half.hpp` is part of the public C++ API,
6// and `rerun.hpp` must not leak the C header (see `tests/header_checks.cpp`).
7extern "C" uint16_t rr_f16_from_f32(float value);
8
9namespace rerun {
10 /// IEEE 754 16-bit half-precision floating point number.
11 struct half {
12 uint16_t f16;
13
14 /// Converts a 32-bit `float` to a 16-bit `half`, rounding to nearest, ties to even.
15 ///
16 /// Values too large to represent become infinity, and `NaN` stays `NaN`.
17 static half from_float(float value) {
18 half result;
19 result.f16 = rr_f16_from_f32(value);
20 return result;
21 }
22 };
23} // namespace rerun
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
IEEE 754 16-bit half-precision floating point number.
Definition half.hpp:11
static half from_float(float value)
Converts a 32-bit float to a 16-bit half, rounding to nearest, ties to even.
Definition half.hpp:17