A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../algorithm/../ranges/../utility/ratio.html below:

Compile-time rational arithmetic (since C++11)

Compile time rational arithmetic

The class template std::ratio and associated templates provide compile-time rational arithmetic support. Each instantiation of this template exactly represents any finite rational number.

[edit] Compile-time fractions represents exact rational fraction
(class template) [edit]

The following convenience typedefs that correspond to the SI ratios are provided by the standard library:

Type Definition quecto (since C++26) std::ratio<1, 1000000000000000000000000000000> (10-30)[1] ronto (since C++26) std::ratio<1, 1000000000000000000000000000>    (10-27)[1] yocto (since C++11) std::ratio<1, 1000000000000000000000000>       (10-24)[1] zepto (since C++11) std::ratio<1, 1000000000000000000000>          (10-21)[1] atto (since C++11) std::ratio<1, 1000000000000000000> (10-18) femto (since C++11) std::ratio<1, 1000000000000000>    (10-15) pico (since C++11) std::ratio<1, 1000000000000>       (10-12) nano (since C++11) std::ratio<1, 1000000000>          (10-9) micro (since C++11) std::ratio<1, 1000000> (10-6) milli (since C++11) std::ratio<1, 1000>    (10-3) centi (since C++11) std::ratio<1, 100>     (10-2) deci (since C++11) std::ratio<1, 10>      (10-1) deca (since C++11) std::ratio<10, 1>      (101) hecto (since C++11) std::ratio<100, 1>     (102) kilo (since C++11) std::ratio<1000, 1>    (103) mega (since C++11) std::ratio<1000000, 1> (106) giga (since C++11) std::ratio<1000000000, 1>          (109) tera (since C++11) std::ratio<1000000000000, 1>       (1012) peta (since C++11) std::ratio<1000000000000000, 1>    (1015) exa (since C++11) std::ratio<1000000000000000000, 1> (1018) zetta (since C++11) std::ratio<1000000000000000000000, 1>          (1021)[2] yotta (since C++11) std::ratio<1000000000000000000000000, 1>       (1024)[2] ronna (since C++26) std::ratio<1000000000000000000000000000, 1>    (1027)[2] quetta (since C++26) std::ratio<1000000000000000000000000000000, 1> (1030)[2]
  1. ↑ 1.0 1.1 1.2 1.3 These typedefs are only declared if std::intmax_t can represent the denominator.
  2. ↑ 2.0 2.1 2.2 2.3 These typedefs are only declared if std::intmax_t can represent the numerator.
[edit] Compile-time rational arithmetic

Several alias templates, that perform arithmetic operations on ratio objects at compile-time are provided.

[edit] Compile-time rational comparison

Several class templates, that perform comparison operations on ratio objects at compile-time are provided.

compares two ratio objects for equality at compile-time
(class template) [edit] compares two ratio objects for inequality at compile-time
(class template) [edit] compares two ratio objects for less than at compile-time
(class template) [edit] compares two ratio objects for less than or equal to at compile-time
(class template) [edit] compares two ratio objects for greater than at compile-time
(class template) [edit] compares two ratio objects for greater than or equal to at compile-time
(class template) [edit]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4