tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
ratio< Num, Denom > Struct Template Reference

The typename template provides compile-time rational arithmetic support. Each instantiation of this template exactly represents any finite rational number as long as its numerator Num and denominator Denom are representable as compile-time constants of type intmax_t. More...

#include <ratio.hpp>

Public Types

using type = ratio<num, den>
 

Static Public Attributes

static constexpr intmax_t den = abs(Denom) / gcd(Num, Denom)
 
static constexpr intmax_t num = detail::sign(Num) * detail::sign(Denom) * abs(Num) / gcd(Num, Denom)
 

Detailed Description

template<intmax_t Num, intmax_t Denom = 1>
struct etl::ratio< Num, Denom >

The typename template provides compile-time rational arithmetic support. Each instantiation of this template exactly represents any finite rational number as long as its numerator Num and denominator Denom are representable as compile-time constants of type intmax_t.

Member Typedef Documentation

◆ type

template<intmax_t Num, intmax_t Denom = 1>
using type = ratio<num, den>

Member Data Documentation

◆ den

template<intmax_t Num, intmax_t Denom = 1>
intmax_t den = abs(Denom) / gcd(Num, Denom)
staticconstexpr

◆ num

template<intmax_t Num, intmax_t Denom = 1>
intmax_t num = detail::sign(Num) * detail::sign(Denom) * abs(Num) / gcd(Num, Denom)
staticconstexpr

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