|
8 | 8 | ``` |
9 | 9 |
|
10 | 10 | ## 概要 |
11 | | -[`int_fast8_t`](int_fast8_t.md) の最大値。 |
| 11 | +[`int_fast8_t`](int_fast8_t.md) の最大値を表す定数。 |
| 12 | +
|
| 13 | +[`std::numeric_limits`](/reference/limits/numeric_limits.md)`<int_fast8_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_FAST8_MAX: " << INT_FAST8_MAX << std::endl; |
| 24 | + |
| 25 | + // numeric_limitsによる値と一致することを確認 |
| 26 | + std::cout << "numeric_limits<int_fast8_t>::max(): " |
| 27 | + << static_cast<int>(std::numeric_limits<std::int_fast8_t>::max()) << std::endl; |
| 28 | + |
| 29 | + std::cout << "INT_FAST8_MAX == numeric_limits<int_fast8_t>::max(): " |
| 30 | + << std::boolalpha |
| 31 | + << (INT_FAST8_MAX == std::numeric_limits<std::int_fast8_t>::max()) << std::endl; |
| 32 | + |
| 33 | + // 型の確認 |
| 34 | + std::int_fast8_t max_value = INT_FAST8_MAX; |
| 35 | + std::cout << "型を通したときの値: " << static_cast<int>(max_value) << std::endl; |
| 36 | + |
| 37 | + // オーバーフローの確認 |
| 38 | + std::int_fast8_t value = INT_FAST8_MAX; |
| 39 | + std::cout << "INT_FAST8_MAX: " << static_cast<int>(value) << std::endl; |
| 40 | + std::cout << "INT_FAST8_MAX + 1: " << static_cast<int>(value + 1) << std::endl; |
| 41 | + |
| 42 | + return 0; |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +### 出力例 |
| 47 | +``` |
| 48 | +INT_FAST8_MAX: 127 |
| 49 | +numeric_limits<int_fast8_t>::max(): 127 |
| 50 | +INT_FAST8_MAX == numeric_limits<int_fast8_t>::max(): true |
| 51 | +型を通したときの値: 127 |
| 52 | +INT_FAST8_MAX: 127 |
| 53 | +INT_FAST8_MAX + 1: -128 |
| 54 | +``` |
| 55 | +
|
| 56 | +この出力例は処理系によって異なる場合がある。特に、`int_fast8_t`の実際の型が処理系によって異なる可能性があるため、最大値やオーバーフロー動作も異なることがある。 |
12 | 57 |
|
13 | 58 | ## バージョン |
14 | 59 | ### 言語 |
15 | 60 | - C++11 |
16 | 61 |
|
17 | 62 | ### 処理系 |
18 | | -- [Clang](/implementation.md#clang): 3.2 [mark verified] |
19 | | -- [GCC](/implementation.md#gcc): 4.7.0 [mark verified] |
| 63 | +- [Clang](/implementation.md#clang): 3.2 |
| 64 | +- [GCC](/implementation.md#gcc): 4.7.0 |
20 | 65 | - [ICC](/implementation.md#icc): ?? |
21 | | -- [Visual C++](/implementation.md#visual_cpp): 2010 [mark verified], 2012 [mark verified], 2013 [mark verified] |
| 66 | +- [Visual C++](/implementation.md#visual_cpp): 2010, 2012, 2013 |
| 67 | +
|
| 68 | +## 参照 |
| 69 | +- [`<cstdint>`](/reference/cstdint.md) |
| 70 | +- [`int_fast8_t`](int_fast8_t.md) |
0 commit comments