Skip to content

Commit 28c1ed5

Browse files
committed
reference/cstdint/int_fast64_t.md: Created sample program
1 parent c476d9c commit 28c1ed5

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

reference/cstdint/int_fast64_t.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,55 @@ namespace std {
1616
1717
[`int64_t`](int64_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_fast64_tの使用例
29+
std::int_fast64_t value = 1234567890123456789LL;
30+
31+
// 値を出力
32+
std::cout << "value: " << value << std::endl;
33+
34+
// サイズを確認(処理系によって異なる可能性がある)
35+
std::cout << "size of int_fast64_t: " << sizeof(std::int_fast64_t) << " bytes" << std::endl;
36+
37+
// 最小値と最大値
38+
std::cout << "minimum value: " << std::numeric_limits<std::int_fast64_t>::min() << std::endl;
39+
std::cout << "maximum value: " << std::numeric_limits<std::int_fast64_t>::max() << std::endl;
40+
41+
// int64_tとの比較
42+
std::cout << "int_fast64_t is the same as int64_t: "
43+
<< std::is_same<std::int_fast64_t, std::int64_t>::value << std::endl;
44+
45+
// 演算の例(オーバーフローに注意)
46+
std::int_fast64_t a = 9000000000000000000LL;
47+
std::int_fast64_t b = 1000000000000000000LL;
48+
std::int_fast64_t sum = a + b; // 処理系によってはオーバーフローの可能性あり
49+
50+
std::cout << "9000000000000000000 + 1000000000000000000 = " << sum << std::endl;
51+
52+
return 0;
53+
}
54+
```
55+
56+
### 出力例
57+
```
58+
value: 1234567890123456789
59+
size of int_fast64_t: 8 bytes
60+
minimum value: -9223372036854775808
61+
maximum value: 9223372036854775807
62+
int_fast64_t is the same as int64_t: 0
63+
9000000000000000000 + 1000000000000000000 = -8446744073709551616
64+
```
65+
66+
この出力例は特定の環境に依存しており、処理系によって異なる可能性があります。特に、`int_fast64_t`のサイズやオーバーフロー動作は処理系によって異なることがある。
67+
1968
## バージョン
2069
### 言語
2170
- C++11
@@ -25,3 +74,8 @@ namespace std {
2574
- [GCC](/implementation.md#gcc): 4.7.0 [mark verified]
2675
- [ICC](/implementation.md#icc): ??
2776
- [Visual C++](/implementation.md#visual_cpp): 2010 [mark verified], 2012 [mark verified], 2013 [mark verified]
77+
78+
## 参照
79+
- [`<cstdint>`](/reference/cstdint.md)
80+
- [`INT_FAST64_MIN`](int_fast64_min.md)
81+
- [`INT_FAST64_MAX`](int_fast64_max.md)

0 commit comments

Comments
 (0)