FDL Core Library
ASC Framing Decision List — C/C++ Reference Implementation
Loading...
Searching...
No Matches
Functions
fdl_rounding.cpp File Reference

FDL rounding functions (round, round_dimensions, round_point) using banker's rounding. More...

#include "fdl_rounding.h"
#include "fdl/fdl_core.h"
#include <cmath>
#include <cstdlib>

Functions

int64_t fdl_round (double value, fdl_rounding_even_t even, fdl_rounding_mode_t mode)
 Round a single value according to FDL rounding rules.
 
fdl_dimensions_f64_t fdl_round_dimensions (fdl_dimensions_f64_t dims, fdl_rounding_even_t even, fdl_rounding_mode_t mode)
 Round dimensions according to FDL rounding rules.
 
fdl_point_f64_t fdl_round_point (fdl_point_f64_t point, fdl_rounding_even_t even, fdl_rounding_mode_t mode)
 Round a point according to FDL rounding rules.
 

Detailed Description

FDL rounding functions (round, round_dimensions, round_point) using banker's rounding.

Function Documentation

◆ fdl_round()

int64_t fdl_round ( double  value,
fdl_rounding_even_t  even,
fdl_rounding_mode_t  mode 
)

Round a single value according to FDL rounding rules.

Parameters
valueThe floating-point value to round.
evenEven constraint (FDL_ROUNDING_EVEN_WHOLE or _EVEN).
modeRounding direction (FDL_ROUNDING_MODE_UP, _DOWN, or _ROUND).
Returns
Rounded integer value.

◆ fdl_round_dimensions()

fdl_dimensions_f64_t fdl_round_dimensions ( fdl_dimensions_f64_t  dims,
fdl_rounding_even_t  even,
fdl_rounding_mode_t  mode 
)

Round dimensions according to FDL rounding rules.

Parameters
dimsDimensions to round.
evenEven constraint.
modeRounding direction.
Returns
Rounded dimensions (both width and height rounded independently).

◆ fdl_round_point()

fdl_point_f64_t fdl_round_point ( fdl_point_f64_t  point,
fdl_rounding_even_t  even,
fdl_rounding_mode_t  mode 
)

Round a point according to FDL rounding rules.

Parameters
pointPoint to round.
evenEven constraint.
modeRounding direction.
Returns
Rounded point (both x and y rounded independently).