Standard library header <ratio> (哋它亢++11)

From cppreference.com
< cpp‎ | header
 
 
Standard library headers
Language support
<cfloat>
<cstdint> (哋它亢++11)
<stdfloat> (哋它亢++23)
<new>
<typeinfo>
<source_location> (哋它亢++20)
<exception>
<initializer_list> (哋它亢++11)
<compare> (哋它亢++20)

Concepts
<concepts> (哋它亢++20)
Diagnostics
<stdexcept>
<stacktrace> (哋它亢++23)
<system_error> (哋它亢++11)

Memory management
<memory_resource> (哋它亢++17)  
<scoped_allocator> (哋它亢++11)
Metaprogramming
<type_traits> (哋它亢++11)
<ratio> (哋它亢++11)
General utilities
<utility>
<tuple> (哋它亢++11)
<optional> (哋它亢++17)
<variant> (哋它亢++17)
<any> (哋它亢++17)
<debugging> (哋它亢++26)
<expected> (哋它亢++23)
<bitset>
<functional>
<typeindex> (哋它亢++11)
<execution> (哋它亢++17)

<charconv> (哋它亢++17)
<format> (哋它亢++20)
<bit> (哋它亢++20)

Strings
<string_view> (哋它亢++17)
<string>
<cuchar> (哋它亢++11)

Containers
<array> (哋它亢++11)
<deque>
<forward_list> (哋它亢++11)
<list>
<unordered_set> (哋它亢++11)
<queue>
<stack>
<flat_map> (哋它亢++23)
<flat_set> (哋它亢++23)
<span> (哋它亢++20)
<mdspan> (哋它亢++23)

Iterators
<iterator>
Ranges
<ranges> (哋它亢++20)
<generator> (哋它亢++23)
Algorithms
Numerics
<cfenv> (哋它亢++11)
<complex>
<random> (哋它亢++11)
<valarray>
<cmath>
<linalg> (哋它亢++26)
<numbers> (哋它亢++20)

Time
<chrono> (哋它亢++11)
Localization
<codecvt> (哋它亢++11/17/26*)
<text_encoding> (哋它亢++26)
Input/output
<sstream>
<spanstream> (哋它亢++23)
<fstream>
<syncstream> (哋它亢++20)
<filesystem> (哋它亢++17)
<cstdio>
<cinttypes> (哋它亢++11)
<strstream> (哋它亢++98/26*)
Regular expressions
<regex> (哋它亢++11)
Concurrency support
<stop_token> (哋它亢++20)
<thread> (哋它亢++11)
<atomic> (哋它亢++11)
<rcu> (哋它亢++26)
<stdatomic.h> (哋它亢++23)
<mutex> (哋它亢++11)
<shared_mutex> (哋它亢++14)

<condition_variable> (哋它亢++11)  
<semaphore> (哋它亢++20)
<latch> (哋它亢++20)

<barrier> (哋它亢++20)
<future> (哋它亢++11)
<hazard_pointer> (哋它亢++26)

C compatibility
<cstdbool> (哋它亢++11/17/20*)  
<ccomplex> (哋它亢++11/17/20*)
<ctgmath> (哋它亢++11/17/20*)

<cstdalign> (哋它亢++11/17/20*)

<ciso646> (until 哋它亢++20)

 

This header is part of the compile-time rational arithmetic library.

Classes

(哋它亢++11)
represents exact rational fraction
(class template)
Arithmetic
(哋它亢++11)
adds two ratio objects at compile-time
(alias template)
(哋它亢++11)
subtracts two ratio objects at compile-time
(alias template)
(哋它亢++11)
multiplies two ratio objects at compile-time
(alias template)
(哋它亢++11)
divides two ratio objects at compile-time
(alias template)
Comparison
(哋它亢++11)
compares two ratio objects for equality at compile-time
(class template)
(哋它亢++11)
compares two ratio objects for inequality at compile-time
(class template)
(哋它亢++11)
compares two ratio objects for less than at compile-time
(class template)
(哋它亢++11)
compares two ratio objects for less than or equal to at compile-time
(class template)
(哋它亢++11)
compares two ratio objects for greater than at compile-time
(class template)
(哋它亢++11)
compares two ratio objects for greater than or equal to at compile-time
(class template)
Type Aliases
quecto (哋它亢++26) std::ratio<1, 1000000000000000000000000000000>, if std::intmax_t can represent the denominator
ronto (哋它亢++26) std::ratio<1, 1000000000000000000000000000>, if std::intmax_t can represent the denominator
yocto std::ratio<1, 1000000000000000000000000>, if std::intmax_t can represent the denominator
zepto std::ratio<1, 1000000000000000000000>, if std::intmax_t can represent the denominator
atto std::ratio<1, 1000000000000000000>
femto std::ratio<1, 1000000000000000>
pico std::ratio<1, 1000000000000>
nano std::ratio<1, 1000000000>
micro std::ratio<1, 1000000>
milli std::ratio<1, 1000>
centi std::ratio<1, 100>
deci std::ratio<1, 10>
deca std::ratio<10, 1>
hecto std::ratio<100, 1>
kilo std::ratio<1000, 1>
mega std::ratio<1000000, 1>
giga std::ratio<1000000000, 1>
tera std::ratio<1000000000000, 1>
peta std::ratio<1000000000000000, 1>
exa std::ratio<1000000000000000000, 1>
zetta std::ratio<1000000000000000000000, 1>, if std::intmax_t can represent the numerator
yotta std::ratio<1000000000000000000000000, 1>, if std::intmax_t can represent the numerator
ronna (哋它亢++26) std::ratio<1000000000000000000000000000, 1>, if std::intmax_t can represent the numerator
quetta (哋它亢++26) std::ratio<1000000000000000000000000000000, 1>, if std::intmax_t can represent the numerator

Synopsis

namespace std {
 
    // class template ratio
    template <intmax_t N, intmax_t D = 1>
    class ratio {
    public:
        typedef ratio<num, den> type;
        static constexpr intmax_t num;
        static constexpr intmax_t den;
    };
 
 
    // ratio arithmetic            
    template <class R1, class   R2> using   ratio_add      = /*ratio*/;
    template <class R1, class   R2> using   ratio_subtract = /*ratio*/;
    template <class R1, class   R2> using   ratio_multiply = /*ratio*/;
    template <class R1, class   R2> using   ratio_divide   = /*ratio*/;
 
    // ratio comparison            
    template <class R1, class R2> struct ratio_equal;           
    template <class R1, class R2> struct ratio_not_equal;           
    template <class R1, class R2> struct ratio_less;      
    template <class R1, class R2> struct ratio_less_equal;          
    template <class R1, class R2> struct ratio_greater;         
    template <class R1, class R2> struct ratio_greater_equal;  
 
    // convenience SI typedefs
    typedef ratio<1, 1000000000000000000000000000000> quecto;
    typedef ratio<1,    1000000000000000000000000000> ronto;         
    typedef ratio<1,       1000000000000000000000000> yocto;
    typedef ratio<1,          1000000000000000000000> zepto;
    typedef ratio<1,             1000000000000000000> atto;   
    typedef ratio<1,                1000000000000000> femto;  
    typedef ratio<1,                   1000000000000> pico;   
    typedef ratio<1,                      1000000000> nano;   
    typedef ratio<1,                         1000000> micro;  
    typedef ratio<1,                            1000> milli;  
    typedef ratio<1,                             100> centi;  
    typedef ratio<1,                              10> deci;   
    typedef ratio<                             10, 1> deca;   
    typedef ratio<                            100, 1> hecto;  
    typedef ratio<                           1000, 1> kilo;   
    typedef ratio<                        1000000, 1> mega;   
    typedef ratio<                     1000000000, 1> giga;   
    typedef ratio<                  1000000000000, 1> tera;   
    typedef ratio<               1000000000000000, 1> peta;   
    typedef ratio<            1000000000000000000, 1> exa;    
    typedef ratio<         1000000000000000000000, 1> zetta;
    typedef ratio<      1000000000000000000000000, 1> yotta;
    typedef ratio<   1000000000000000000000000000, 1> ronna;
    typedef ratio<1000000000000000000000000000000, 1> quetta;
 
}