Skip to content

Commit d571305

Browse files
committed
reference/cstdint/int_fast64_max.md: Created sample program
1 parent 4bfaf75 commit d571305

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

reference/cstdint/int_fast64_max.md

+46-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,52 @@
88
```
99
1010
## 概要
11-
[`int_fast64_t`](int_fast64_t.md) の最大値。
11+
[`int_fast64_t`](int_fast64_t.md) の最大値を表す定数。
12+
13+
[`std::numeric_limits`](/reference/limits/numeric_limits.md)`<int_fast64_t>::`[`max()`](/reference/limits/numeric_limits/max.md) と等しい。
14+
15+
## 例
16+
```cpp example
17+
#include <iostream>
18+
#include <cstdint>
19+
#include <limits>
20+
21+
int main()
22+
{
23+
std::cout << "INT_FAST64_MAX: " << INT_FAST64_MAX << std::endl;
24+
25+
// numeric_limitsによる値と一致することを確認
26+
std::cout << "numeric_limits<int_fast64_t>::max(): "
27+
<< std::numeric_limits<std::int_fast64_t>::max() << std::endl;
28+
29+
std::cout << "INT_FAST64_MAX == numeric_limits<int_fast64_t>::max(): "
30+
<< std::boolalpha
31+
<< (INT_FAST64_MAX == std::numeric_limits<std::int_fast64_t>::max()) << std::endl;
32+
33+
// 型の確認
34+
std::int_fast64_t max_value = INT_FAST64_MAX;
35+
std::cout << "型を通したときの値: " << max_value << std::endl;
36+
37+
// オーバーフローの確認
38+
std::int_fast64_t value = INT_FAST64_MAX;
39+
std::cout << "INT_FAST64_MAX: " << value << std::endl;
40+
std::cout << "INT_FAST64_MAX + 1: " << value + 1 << std::endl;
41+
42+
return 0;
43+
}
44+
```
45+
46+
### 出力例
47+
```
48+
INT_FAST64_MAX: 9223372036854775807
49+
numeric_limits<int_fast64_t>::max(): 9223372036854775807
50+
INT_FAST64_MAX == numeric_limits<int_fast64_t>::max(): true
51+
型を通したときの値: 9223372036854775807
52+
INT_FAST64_MAX: 9223372036854775807
53+
INT_FAST64_MAX + 1: -9223372036854775808
54+
```
55+
56+
この出力例は処理系によって異なる場合がある。特に、`int_fast64_t`の実際の型が処理系によって異なる可能性があるため、最大値やオーバーフロー動作も異なることがある。
1257
1358
## バージョン
1459
### 言語

0 commit comments

Comments
 (0)