GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::ratio(3) C++ Standard Libary std::ratio(3)

std::ratio - std::ratio


Defined in header <ratio>
template<


std::intmax_t Num, (since C++11)
std::intmax_t Denom = 1


> class ratio;


The class template std::ratio 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 std::intmax_t. In addition, Denom may not be zero and may not be
equal to the most negative value.


The static data members num and den representing the numerator and denominator are
calculated by dividing Num and Denom by their greatest common divisor. However, two
std::ratio with different Num or Denom are distinct types even if they represent the
same rational number (after reduction). A ratio type can be reduced to the lowest
terms via its type member: std::ratio<3, 6>::type is std::ratio<1, 2>.


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


Defined in header <ratio>
Type Definition
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


Member type Definition
type std::ratio<num, den>


constexpr intmax_t num constexpr value of type std::intmax_t equal to sign(Denom) *
[static] Num / gcd(Num, Denom)
(public static member constant)
constexpr intmax_t den constexpr value of type std::intmax_t equal to abs(Denom) /
[static] gcd(Num, Denom)
(public static member constant)


Mathematical constants (C++20) provides several mathematical constants, such as
std::numbers::e for e

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.