DPDK  18.11.11
Functions
rte_approx.h File Reference
#include <stdint.h>

Go to the source code of this file.

Functions

int rte_approx (double alpha, double d, uint32_t *p, uint32_t *q)
 

Detailed Description

RTE Rational Approximation

Given a rational number alpha with 0 < alpha < 1 and a precision d, the goal is to find positive integers p, q such that alpha - d < p/q < alpha + d, and q is minimal.

Definition in file rte_approx.h.

Function Documentation

int rte_approx ( double  alpha,
double  d,
uint32_t *  p,
uint32_t *  q 
)

Find best rational approximation

Parameters
alphaRational number to approximate
dPrecision for the rational approximation
pPointer to pre-allocated space where the numerator of the rational approximation will be stored when operation is successful
qPointer to pre-allocated space where the denominator of the rational approximation will be stored when operation is successful
Returns
0 upon success, error code otherwise