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