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[`int8_t`](int8_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_fast8_tの使用例
29+ std::int_fast8_t value = 42;
30+
31+ // 値を出力
32+ std::cout << "value: " << static_cast<int>(value) << std::endl;
33+
34+ // サイズを確認(処理系によって異なる可能性がある)
35+ std::cout << "size of int_fast8_t: " << sizeof(std::int_fast8_t) << " bytes" << std::endl;
36+
37+ // 最小値と最大値
38+ std::cout << "minimum value: " << static_cast<int>(std::numeric_limits<std::int_fast8_t>::min()) << std::endl;
39+ std::cout << "maximum value: " << static_cast<int>(std::numeric_limits<std::int_fast8_t>::max()) << std::endl;
40+
41+ // int8_tとの比較
42+ std::cout << "int_fast8_t is the same as int8_t: "
43+ << std::is_same<std::int_fast8_t, std::int8_t>::value << std::endl;
44+
45+ // 演算の例(オーバーフローに注意)
46+ std::int_fast8_t a = 100;
47+ std::int_fast8_t b = 50;
48+ std::int_fast8_t sum = a + b; // 処理系によってはオーバーフローの可能性あり
49+
50+ std::cout << "100 + 50 = " << static_cast<int>(sum) << std::endl;
51+
52+ return 0;
53+ }
54+ ```
55+
56+ ### 出力例
57+ ```
58+ value: 42
59+ size of int_fast8_t: 1 bytes
60+ minimum value: -128
61+ maximum value: 127
62+ int_fast8_t is the same as int8_t: 0
63+ 100 + 50 = -106
64+ ```
65+
66+ この出力例は特定の環境に依存しており、処理系によって異なる可能性があります。特に、` int_fast8_t ` のサイズやオーバーフロー動作は処理系によって異なることがある。
67+
1968## バージョン
2069### 言語
2170- C++11
You can’t perform that action at this time.
0 commit comments