Compile-time rational arithmetic
From Cppreference
| C++ Standard Library | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Numerics library | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile time rational arithmetic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[edit] ratio
| Defined in header <ratio>
|
||
| template<
intmax_t Num, |
(since C++11) | |
The class template ratio provides compile-time rational arithmetic support.
| This section is incomplete |
Several convenience SI typedefs are already provided:
| Defined in header <ratio>
|
||
| typedef std::ratio<1, 1000000000000000000000000> yocto; //see below
typedef std::ratio<1, 1000000000000000000000> zepto; //see below |
(since C++11) | |
The typedefs yocto, zepto, zetta, yotta are provided only if intmax_t is sufficient to represent the values used to instantiate the templates.
[edit] ratio arithmetic
Several class templates, that perform arithmetic operations on ratio objects at compile-time are provided.
| Defined in header <ratio>
| |
| (C++11)
|
adds two ratio objects at compile-time (class template) |
| (C++11)
|
subtracts two ratio objects at compile-time (class template) |
| (C++11)
|
multiplies two ratio objects at compile-time (class template) |
| (C++11)
|
divides two ratio objects at compile-time (class template) |
[edit] ratio comparison
Several class templates, that perform comparison operations on ratio objects at compile-time are provided.
| Defined in header <ratio>
| |
| (C++11)
|
compares two ratio objects for equality at compile-time (class template) |
| (C++11)
|
compares two ratio objects for inequality at compile-time (class template) |
| (C++11)
|
compares two ratio objects for less than at compile-time (class template) |
| (C++11)
|
compares two ratio objects for less than or equal to at compile-time (class template) |
| (C++11)
|
compares two ratio objects for greater than at compile-time (class template) |
| (C++11)
|
compares two ratio objects for greater than or equal to at compile-time (class template) |