Abh*_*hek -1 c++ gcc types largenumber
我有一个程序需要存储几个数字.最大的可以是10 ^ 15的量级.我应该如何存储号码.
我正在使用Gcc 4.3.2编译器.
long long 因为它是64位,所以适合10 ^ 15.
要查看所有数据类型的限制值,可以使用<limits>标题.
#include <iostream>
#include <limits>    
int main() {
    //print maximum of various types
    std::cout << "Maximum values :\n";
    std::cout << "Short : " << std::numeric_limits<short>::max() << std::endl;
    std::cout << "Int : " << std::numeric_limits<int>::max() << std::endl;
    std::cout << "Long : " << std::numeric_limits<long>::max() << std::endl;
    std::cout << "Long Long: " << std::numeric_limits<long long>::max() << std::endl;
    std::cout << "Float : " << std::numeric_limits<float>::max() << std::endl;
    std::cout << "Double : " << std::numeric_limits<double>::max() << std::endl;
    //print minimum of various types
    std::cout << "\n";
    std::cout << "Minimum Values: \n";
    std::cout << "Short : " << std::numeric_limits<short>::min() << std::endl;
    std::cout << "Int : " << std::numeric_limits<int>::min() << std::endl;
    std::cout << "Long : " << std::numeric_limits<long>::min() << std::endl;
    std::cout << "Long Long: " << std::numeric_limits<long long>::min() << std::endl;
    std::cout << "Float : " << std::numeric_limits<float>::min() << std::endl;
    std::cout << "Double : " << std::numeric_limits<double>::min() << std::endl;
}
哪个输出(在我的机器上):
Maximum values :
Short : 32767
Int : 2147483647
Long : 2147483647
Long Long: 9223372036854775807
Float : 3.40282e+038
Double : 1.79769e+308
Minimum Values: 
Short : -32768
Int : -2147483648
Long : -2147483648
Long Long: -9223372036854775808
Float : 1.17549e-038
Double : 2.22507e-308
| 归档时间: | 
 | 
| 查看次数: | 8352 次 | 
| 最近记录: |