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

Function toInt64

pj_scripting/src/lua_siso_transform.cpp:18–29  ·  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

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

Callers 1

makeOutputValueMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected