std::numeric_limits::lowest

static constexpr T lowest()
(C++11 起)

返回数值类型 T 可表示的最低有限值,即满足无其他有限值 y 符合 y < x 的有限值 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++ 浮点类型非真,可存在满足 std::numeric_limits<T>::lowest() != -std::numeric_limits<T>::max() 的第三方浮点类型 T

异常

(无) (C++11 前)
noexcept 规定:  
noexcept
  
(C++11 起)

示例

为浮点类型演示 min 、 max 及 lowest

#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';
}

输出:

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

参阅

[静态]
返回给定类型的最小有限值
(公开静态成员函数)
[静态]
返回给定浮点类型的最小正非正规值
(公开静态成员函数)
[静态]
返回给定类型的最大有限值
(公开静态成员函数)

版本历史

  • (当前 | 先前 2017年7月16日 (日) 21:37Fruderica讨论 | 贡献. . (3,783字节) (-791). . (撤销)
  • 当前 | 先前 2014年10月26日 (日) 18:17P12bot讨论 | 贡献 . . (4,574字节) (0). . (Fix some translations) (撤销)
  • 当前 | 先前 2013年7月2日 (二) 11:48P12bot讨论 | 贡献 . . (4,574字节) (-290). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 14:54P12bot讨论 | 贡献 . . (4,864字节) (+313). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月27日 (六) 12:12P12讨论 | 贡献 . . (4,551字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 06:00TranslationBot讨论 | 贡献. . (4,551字节) (-48). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 03:54P12讨论 | 贡献 . . (4,599字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (4,599字节) (+4,599). . (Translated from the English version using Google Translate)