File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,55 @@ namespace std {
1616
1717[`int16_t`](int16_t.md)型が環境によっては定義されないため、そのような状況でこの型を使用する。
1818
19+ ## 例
20+ ```cpp example
21+ #include <iostream>
22+ #include <cstdint>
23+ #include <type_traits>
24+ #include <limits>
25+
26+ int main()
27+ {
28+ // int_fast16_tの使用例
29+ std::int_fast16_t value = 12345;
30+
31+ // 値を出力
32+ std::cout << "value: " << value << std::endl;
33+
34+ // サイズを確認(処理系によって異なる可能性がある)
35+ std::cout << "size of int_fast16_t: " << sizeof(std::int_fast16_t) << " bytes" << std::endl;
36+
37+ // 最小値と最大値
38+ std::cout << "minimum value: " << std::numeric_limits<std::int_fast16_t>::min() << std::endl;
39+ std::cout << "maximum value: " << std::numeric_limits<std::int_fast16_t>::max() << std::endl;
40+
41+ // int16_tとの比較
42+ std::cout << "int_fast16_t is the same as int16_t: "
43+ << std::is_same<std::int_fast16_t, std::int16_t>::value << std::endl;
44+
45+ // 演算の例(オーバーフローに注意)
46+ std::int_fast16_t a = 30000;
47+ std::int_fast16_t b = 10000;
48+ std::int_fast16_t sum = a + b; // 処理系によってはオーバーフローの可能性あり
49+
50+ std::cout << "30000 + 10000 = " << sum << std::endl;
51+
52+ return 0;
53+ }
54+ ```
55+
56+ ### 出力例
57+ ```
58+ value: 12345
59+ size of int_fast16_t: 4 bytes
60+ minimum value: -32768
61+ maximum value: 32767
62+ int_fast16_t is the same as int16_t: 0
63+ 30000 + 10000 = -25536
64+ ```
65+
66+ この出力例は特定の環境に依存しており、処理系によって異なる可能性があります。特に、` int_fast16_t ` のサイズやオーバーフロー動作は処理系によって異なることがある。
67+
1968## バージョン
2069### 言語
2170- C++11
You can’t perform that action at this time.
0 commit comments