---
name: "rte_approx.h"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_approx.h"
---

# rte\_approx.h(3)

## NAME

rte\_approx.h

## SYNOPSIS

`#include <stdint.h>`\

### Functions

int **rte\_approx** (double alpha, double d, uint32\_t \*p, uint32\_t \*q)\
 int **rte\_approx\_64** (double alpha, double d, uint64\_t \*p, uint64\_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**

*alpha* Rational number to approximate \
 *d* Precision for the rational approximation \
 *p* Pointer to pre-allocated space where the numerator of the rational approximation will be stored when operation is successful \
 *q* Pointer 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

### int rte\_approx\_64 (double alpha, double d, uint64\_t \* p, uint64\_t \* q)

Find best rational approximation (64 bit version)

**Parameters**

*alpha* Rational number to approximate \
 *d* Precision for the rational approximation \
 *p* Pointer to pre-allocated space where the numerator of the rational approximation will be stored when operation is successful \
 *q* Pointer 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

## Author

Generated automatically by Doxygen for DPDK from the source code.
