C++中获取一个原生数据类型能表示的最大值

来源:互联网 发布:python anaconda 安装 编辑:程序博客网 时间:2024/06/11 05:24
#include <limits>#include <iostream>using namespace std;int main( ){    int max_int = numeric_limits< int >::max( );    cout << "int: " << sizeof( int );    cout << ", " << max_int << endl;    long max_long = numeric_limits< long >::max( );    cout << "long: " << sizeof( long );    cout << ", " <<  max_long << endl;    float max_float = numeric_limits< float >::max( );    cout << "float: " << sizeof( float );    cout << ", " << max_float << endl;}
0 0