[cpp]double最大值、最小值及正無窮

#include <iostream>
#include <limits>
int main()
{
    double inf = std::numeric_limits<double>::infinity();
    double max = std::numeric_limits<double>::max();
    double min = std::numeric_limits<double>::min();
 
    std::cout << "double inf :" << inf << std::endl;
    std::cout << "double max :" << max << std::endl;
    std::cout << "double min :" << min << std::endl;
    std::cout << "double -inf :" << -inf << std::endl;
    std::cout << "double -max :" << -max << std::endl;
    std::cout << "double -min :" << -min << std::endl;
    return 0;

程序輸出:

double inf :inf
double max :1.79769e+308
double min :2.22507e-308
double -inf :-inf
double -max :-1.79769e+308
double -min :-2.22507e-308
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章