Astd-type_max

该库用于获取各类型的最大值与最小值

代码

宏定义:

#ifndef __TYPE_MAX__ //避免重复
#define __TYPE_MAX__ 202108L
#define __TYPE_MAX_VER_ "1.0.0"
#define __TYPE_MAX_VER_F 1
#define __TYPE_MAX_VER_S 0
#define __TYPE_MAX_VER_T 0
#endif

函数:

inline int int_max(void); //int最大值
inline int int_min(void); //int最小值
inline unsigned int uint_max(void); //unsigned int最大值
inline unsigned int uint_min(void); //unsigned int最小值
inline long long_max(void); //long最大值
inline long long_min(void); //long最小值
inline unsigned long ulong_max(void); //unsigned long最大值
inline unsigned long ulong_min(void); //unsigned long最小值
inline short char_max(void); //char最大值
inline short char_min(void); //char最小值
inline short short_max(void); //short最大值
inline short short_min(void); //short最小值
inline unsigned short ushort_max(void); //unsigned short最大值
inline unsigned short ushort_min(void); //unsigned short最小值
inline int bool_max(void); //bool最大值
inline int bool_min(void); //bool最小值
inline long long ullong_max(void); //long long最大值
inline long long ullong_min(void); //long long最小值
inline float float_max(void); //float最大值
inline float float_min(void); //float最小值
inline double double_max(void); //double最大值
inline double double_min(void); //double最小值

用法举例:

#include <iostream>
#include "type_max.h"
using std::cout;
using std::endl;
using namespace astd;

int main()
{
    cout << int_max() << endl;
    cout << int_min() << endl;
    cout << uint_max() << endl;
    cout << uint_min() << endl;
    cout << long_max() << endl;
    cout << long_min() << endl;
    cout << ulong_max() << endl;
    cout << ulong_min() << endl;
    cout << ullong_max() << endl;
    cout << ullong_min() << endl;
    cout << char_max() << endl;
    cout << char_min() << endl;
    cout << short_max() << endl;
    cout << short_min() << endl;
    cout << ushort_max() << endl;
    cout << ushort_min() << endl;
    cout << bool_max() << endl;
    cout << bool_min() << endl;
    cout << float_max() << endl;
    cout << float_min() << endl;
    cout << double_max() << endl;
    cout << double_min() << endl;
    return 0;
}
输出:
2147483647
-2147483648
4294967295
0
9223372036854775807
-9223372036854775808
18446744073709551615
0
9223372036854775807
-9223372036854775808
127
-128
32767
-32768
65535
0
1
0
3.40282e+38
1.17549e-38
1.79769e+308
2.22507e-308