|
FDL Core Library
ASC Framing Decision List — C/C++ Reference Implementation
|
Banker's rounding (half-to-even) implementation. More...
Go to the source code of this file.
Functions | |
| int64_t | fdl::detail::safe_to_int64 (double value) |
| Safely cast a double to int64_t, clamping to [INT64_MIN, INT64_MAX]. | |
| int64_t | fdl::detail::bankers_round (double value) |
| Banker's rounding (half-to-even), matching Python's built-in round(). | |
Banker's rounding (half-to-even) implementation.
Provides the core rounding primitive that matches Python's built-in round() behavior, ensuring consistent results across the C++ and Python implementations.
|
inline |
Safely cast a double to int64_t, clamping to [INT64_MIN, INT64_MAX].
Prevents undefined behavior from casting doubles that exceed the representable range of int64_t.
| value | The floating-point value to convert. |
|
inline |
Banker's rounding (half-to-even), matching Python's built-in round().
At exact halfway points (e.g. 0.5, 1.5), rounds to the nearest even integer. This avoids systematic rounding bias.
| value | The floating-point value to round. |