stator
A math, geometry, and utility library
Public Types | List of all members
stator::constant_ratio Struct Reference

Physical constants approximated in std::ratio representation. More...

#include <constants.hpp>

Public Types

typedef std::ratio< 28245729, 10391023 > e
 A rational approximation of $\mathrm{e}$. More...
 
typedef std::ratio< 47627751, 15160384 > pi
 A rational approximation of $\pi$. More...
 

Detailed Description

Selecting an appropriate approximation depends on a number of factors. C++11 requires implementations to support at least the long long type (64bits). As std::ratio always uses the maximum size integer to represent its numerator/denominator, std::ratio must support $[-2^{63},+2^{63}-1]$ for the numerator and/or denominator. However, when calculations are performed using std::ratio, sufficient range must be retained for the calculation.

Because of these reasons, we choose rational approximations close to the limits of double precision, or slightly less accurate approximations where increased precision would require a dramatic increase in the magnitude of the numerator/denominator terms.

Definition at line 85 of file constants.hpp.

Member Typedef Documentation

◆ e

typedef std::ratio<28245729, 10391023> stator::constant_ratio::e

The rational approximation, plus the remainder:

\[ \mathrm{e} = \frac{28245729}{10391023} + 8.8817841970012523\ldots\times10^{-16} \]

Definition at line 103 of file constants.hpp.

◆ pi

typedef std::ratio<47627751, 15160384> stator::constant_ratio::pi

The rational approximation, plus the remainder:

\[ \pi = \frac{47627751}{15160384} + 1.5987211554602254\ldots\times10^{-14} \]

Definition at line 93 of file constants.hpp.


The documentation for this struct was generated from the following file: