首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::numeric_limits::lowest

static constexpr T lowest()

?

(since C++11)

返回由数值类型表示的最低限值。T,即有限值x以至于没有其他的有限值y何地y < x这与std::numeric_limits<T>::min()用于浮点类型。仅对有界类型有意义。

返回值

T

std::numeric_limits<T>::lowest()

/* non-specialized */

T();

bool

false

char

CHAR_MIN

signed char

SCHAR_MIN

unsigned char

?0?

wchar_t

WCHAR_MIN

char16_t

?0?

char32_t

?0?

short

SHRT_MIN

unsigned short

?0?

int

INT_MIN

unsigned int

?0?

long

LONG_MIN

unsigned long

?0?

long long

LLONG_MIN

unsigned long long

?0?

float

-FLT_MAX

double

-DBL_MAX

long double

-LDBL_MAX

注记

对于基本C++浮点类型,第三方浮点类型不适用于%27 s。T可能存在于std::numeric_limits<T>::lowest()!=-std::numeric_limits<T>::max()...

例外

(none)

(until C++11)

noexcept specification: noexcept

(since C++11)

演示浮点类型的最小、最大和最低。

二次

代码语言:javascript
复制
#include <limits>
#include <iostream>
int main()
{
 
    std::cout << "std::numeric_limits<T>::min():\n"
              << "\tfloat: " << std::numeric_limits<float>::min()
              << " or " << std::hexfloat << std::numeric_limits<float>::min() << '\n'
              << "\tdouble: " << std::defaultfloat << std::numeric_limits<double>::min()
              << " or " << std::hexfloat << std::numeric_limits<double>::min() << '\n';
    std::cout << "std::numeric_limits<T>::lowest():\n"
              << "\tfloat: " << std::defaultfloat << std::numeric_limits<float>::lowest()
              << " or " << std::hexfloat << std::numeric_limits<float>::lowest() << '\n'
              << "\tdouble: " << std::defaultfloat << std::numeric_limits<double>::lowest()
              << " or " << std::hexfloat << std::numeric_limits<double>::lowest() << '\n';
    std::cout << "std::numeric_limits<T>::max():\n"
              << "\tfloat: " << std::defaultfloat << std::numeric_limits<float>::max()
              << " or " << std::hexfloat << std::numeric_limits<float>::max() << '\n'
              << "\tdouble: " << std::defaultfloat << std::numeric_limits<double>::max()
              << " or " << std::hexfloat << std::numeric_limits<double>::max() << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
std::numeric_limits<T>::min():
        float: 1.17549e-38 or 0x1p-126
        double: 2.22507e-308 or 0x1p-1022
std::numeric_limits<T>::lowest():
        float: -3.40282e+38 or -0x1.fffffep+127
        double: -1.79769e+308 or -0x1.fffffffffffffp+1023
std::numeric_limits<T>::max():
        float: 3.40282e+38 or 0x1.fffffep+127
        double: 1.79769e+308 or 0x1.fffffffffffffp+1023

二次

另见

min static

returns the smallest finite value of the given type (public static member function)

denorm_min static

returns the smallest positive subnormal value of the given floating-point type (public static member function)

max static

returns the largest finite value of the given type (public static member function)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com