LoginSignup
1
1

More than 1 year has passed since last update.

[C++] 色んな型の上限・下限を取得する

Last updated at Posted at 2021-08-28

はじめに

C++でアルゴリズム勉強している過程で得た知識の備忘録です。

色んな型の 無限大 上限値

<limit>パッケージを読み込むことで、いろんな型の 無限大 上限値・下限値を取得できます。

 double max_double = numeric_limits<double>::max();
 float max_float = numeric_limits<float>::max();
 int max_int = numeric_limits<int>::max();
 unsigned int max_unsigned_int = numeric_limits<unsigned int>::max();

 cout << "max double = " << max_double << endl;
 cout << "max_float = " << max_float << endl;
 cout << "max_int = " << max_int << endl;
 cout << "max_unsigned_int = " << max_unsigned_int << endl;

結果

max double = 1.79769e+308
max_float = 3.40282e+38
max_int = 2147483647
max_unsigned_int = 4294967295
1
1
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1