std::ratio_subtract

從 cppreference.com
< cpp‎ | numeric‎ | ratio
在2012年10月25日 (四) 13:00由TranslationBot對話 | 貢獻所做的修訂版本

(差異) ←上一修訂 | 最新修訂 (差異) | 下一修訂→ (差異)

 
 
元編程庫
類型特徵
類型類別
(C++11)
(C++11)(DR*)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11) 
(C++11)
(C++11)
類型屬性
(C++11)
(C++11)
(C++14)
(C++11)(C++26 棄用)
(C++11)(C++20 前*)
(C++11)(C++20 棄用)
(C++11)
類型特徵常量
元函數
(C++17)
受支持操作
關係與屬性查詢
類型修改
(C++11)(C++11)(C++11)
類型變換
(C++11)(C++23 棄用)
(C++11)(C++23 棄用)
(C++11)
(C++11)(C++20 前*)(C++17)

(C++11)
(C++17)
編譯時有理數算術
編譯時整數序列
 
編譯時有理數算術
(C++11)
算術
(C++11)
ratio_subtract
(C++11)
比較
(C++11)
 
<tr class="t-dsc-header"> <td>
在標頭 <ratio> 定義
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td class="t-dcl-nopad">
template< class R1, class R2 >
using ratio_subtract = /* unspecified */;
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr>

。模板別名std::ratio_subtract表示std::ratio的實例所代表的兩個精確合理的分數相減的​​結果R1R2,結果一個std::ratio例如std::ratio<Num, Denom>其中Num == R1::num * R2::den - R2::num * R1::denDenom == R1::den * R2::den.
原文:
The template alias std::ratio_subtract denotes the result of subtracting two exact rational fractions represented by the std::ratio instances R1 and R2. The result a std::ratio instance std::ratio<Num, Denom> where Num == R1::num * R2::den - R2::num * R1::den and Denom == R1::den * R2::den.
文本通過谷歌翻譯機器翻譯。
你可以幫忙校正和驗證翻譯。點擊此處查看指示。

。會員類型。

。會員類型。
原文:
Member type
文本通過谷歌翻譯機器翻譯。
你可以幫忙校正和驗證翻譯。點擊此處查看指示。
Definition
type std::ratio<num, den>

。會員常數。

num
[靜態]
constexpr類型的值std::intmax_t等於sign(Num) * sign(Denom) * abs(Num) / gcd(Num, Denom)
原文:
constexpr value of type std::intmax_t equal to sign(Num) * sign(Denom) * abs(Num) / gcd(Num, Denom)
文本通過谷歌翻譯機器翻譯。
你可以幫忙校正和驗證翻譯。點擊此處查看指示。

(公開靜態成員常量)
den
[靜態]
constexpr類型的值std::intmax_t等於abs(Denom) / gcd(Num, Denom)
原文:
constexpr value of type std::intmax_t equal to abs(Denom) / gcd(Num, Denom)
文本通過谷歌翻譯機器翻譯。
你可以幫忙校正和驗證翻譯。點擊此處查看指示。

(公開靜態成員常量)

。為例。

#include <iostream>
#include <ratio>
 
int main()
{
    typedef std::ratio<2, 3> two_third;
    typedef std::ratio<1, 6> one_sixth;
 
    typedef std::ratio_subtract<two_third, one_sixth> diff;
    std::cout << "2/3 - 1/6 = " << diff::num << '/' << diff::den << '\n';
}

輸出:

2/3 - 1/6 = 1/2