MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / toInt64

Function toInt64

pj_scripting/src/lua_mimo_transform.cpp:19–30  ·  view source on GitHub ↗

Finite-guarded, range-clamped double → int64 (llround of NaN/out-of-range is UB).

Source from the content-addressed store, hash-verified

17namespace {
18// Finite-guarded, range-clamped double → int64 (llround of NaN/out-of-range is UB).
19std::int64_t toInt64(double d) {
20 if (!std::isfinite(d)) {
21 return 0;
22 }
23 if (d >= 9.0e18) {
24 return std::numeric_limits<std::int64_t>::max();
25 }
26 if (d <= -9.0e18) {
27 return std::numeric_limits<std::int64_t>::min();
28 }
29 return static_cast<std::int64_t>(std::llround(d));
30}
31
32// Finite-guarded double → uint64. Negative/non-finite → 0; high band truncates to
33// avoid llround-overflow UB near 2^63 (values there already past double precision).

Callers 1

makeOutputValueMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected