C++ åèæå
- C++11
- C++14
- C++17
- C++20
- C++ ç¼è¯å¨æ¯ææ åµè¡¨
- ç¬ç«ä¸å®¿ä¸»å®ç°
- C++ è¯è¨
- C++ å ³é®è¯
- é¢å¤çå¨
- C++ æ ååºå¤´æä»¶
- å ·åè¦æ±
- åè½ç¹æ§æµè¯ (C++20)
- å·¥å ·åº
- ç±»åæ¯æï¼åºæ¬ç±»åãRTTIãç±»åç¹æ§ï¼
- æ¦å¿µåº (C++20)
- é误å¤ç
- 卿å å管ç
- æ¥æåæ¶é´å·¥å ·
- å符串åº
- 容å¨åº
- è¿ä»£å¨åº
- èå´åº (C++20)
- ç®æ³åº
- æ°å¼åº
- å¸¸ç¨æ°å¦å½æ°
- std::abs(int), std::labs, std::llabs, std::imaxabs
- std::div, std::ldiv, std::lldiv
- std::fmod, std::fmodf, std::fmodl
- std::remainder, std::remainderf, std::remainderl
- std::remquo, std::remquof, std::remquol
- std::hypot, std::hypotf, std::hypotl
- std::abs(float), std::fabs, std::fabsf, std::fabsl
- std::sqrt, std::sqrtf, std::sqrtl
- std::sin, std::sinf, std::sinl
- std::fma, std::fmaf, std::fmal
- std::fmax, std::fmaxf, std::fmaxl
- std::fmin, std::fminf, std::fminl
- std::fdim, std::fdimf, std::fdiml
- NAN
- std::exp, std::expf, std::expl
- std::exp2, std::exp2f, std::exp2l
- std::expm1, std::expm1f, std::expm1l
- std::log, std::logf, std::logl
- std::log10, std::log10f, std::log10l
- std::log1p, std::log1pf, std::log1pl
- std::log2, std::log2f, std::log2l
- std::cbrt, std::cbrtf, std::cbrtl
- std::pow, std::powf, std::powl
- std::cos, std::cosf, std::cosl
- std::tan, std::tanf, std::tanl
- std::asin, std::asinf, std::asinl
- std::acos, std::acosf, std::acosl
- std::atan, std::atanf, std::atanl
- std::atan2, std::atan2f, std::atan2l
- std::sinh, std::sinhf, std::sinhl
- std::cosh, std::coshf, std::coshl
- std::tanh, std::tanhf, std::tanhl
- std::asinh, std::asinhf, std::asinhl
- std::acosh, std::acoshf, std::acoshl
- std::atanh, std::atanh, std::atanhl
- std::erf, std::erff, std::erfl
- std::erfc, std::erfcf, std::erfcl
- std::lgamma, std::lgammaf, std::lgammal
- std::tgamma, std::tgammaf, std::tgammal
- std::ceil, std::ceilf, std::ceill
- std::floor, std::floorf, std::floorl
- std::round, std::roundf, std::roundl, std::lround, std::lroundf, std::lroundl, std::llround, std::llroundf
- std::trunc, std::truncf, std::truncl
- std::nearbyint, std::nearbyintf, std::nearbyintl
- std::rint, std::rintf, std::rintl, std::lrint, std::lrintf, std::lrintl, std::llrint, std::llrintf
- std::ldexp, std::ldexpf, std::ldexpl
- std::scalbn, std::scalbnf, std::scalbnl, std::scalbln, std::scalblnf, std::scalblnl
- std::ilogb, std::ilogbf, std::ilogbl
- std::logb, std::logbf, std::logbl
- std::frexp, std::frexpf, std::frexpl
- std::modf, std::modff, std::modfl
- std::nextafter, std::nextafterf, std::nextafterl, std::nexttoward, std::nexttowardf, std::nexttowardl
- std::copysign, std::copysignf, std::copysignl
- std::fpclassify
- std::isfinite
- std::isinf
- std::isnan
- std::isnormal
- std::signbit
- std::isgreater
- std::isgreaterequal
- std::isless
- std::islessequal
- std::islessgreater
- std::isunordered
- HUGE_VALF, HUGE_VAL, HUGE_VALL
- INFINITY
- MATH_ERRNO, MATH_ERREXCEPT, math_errhandling
- FP_NORMAL, FP_SUBNORMAL, FP_ZERO, FP_INFINITE, FP_NAN
- std::midpoint
- std::lerp
- std::has_single_bit
- std::bit_ceil
- std::bit_floor
- std::bit_width
- std::rotl
- æ°å¦ç¹æ®å½æ°
- ä¼ªéæºæ°çæ
- æµ®ç¹ç¯å¢
- std::complex
- std::valarray
- ç¼è¯æ¶æçæ°ç®æ¯
- std::gcd
- std::lcm
- æ°å¦å¸¸æ°
- std::bit_cast
- std::rotr
- std::countl_zero
- std::countl_one
- std::countr_zero
- std::countr_one
- std::popcount
- 注é
- è¾å ¥/è¾åºåº
- æä»¶ç³»ç»åº
- æ¬å°ååº
- æ£å表达å¼åº
- ååæä½åº
- çº¿ç¨æ¯æåº
- å®éªæ§ C++ ç¹æ§
- æç¨çèµæº
- ç´¢å¼
- std 符å·ç´¢å¼
- åç¨æ¯æ (C++20)
- C++ å ³é®è¯
ä½ç½®ï¼é¦é¡µ > C++ åèæå >æ°å¼åº >å¸¸ç¨æ°å¦å½æ° > std::logb, std::logbf, std::logbl
std::logb, std::logbf, std::logbl
| å®ä¹äºå¤´æä»¶ <cmath>
|
||
| float    logb ( float arg ); float    logbf( float arg ); |
(1) | (C++11 èµ·) |
| double    logb ( double arg ); |
(2) | (C++11 èµ·) |
| long double logb ( long double arg ); long double logbl( long double arg ); |
(3) | (C++11 èµ·) |
| double    logb ( IntegralType arg ); |
(4) | (C++11 èµ·) |
arg æåç¬ç«äºåºåºçæ åææ°ï¼å¹¶å°å®ä½ä¸ºæµ®ç¹å¼è¿åãæ£å¼èè¨ï¼æ åææ°æ¯éé¶ arg ç log
r|arg| çæç¬¦å·æ´æ°é¨åï¼æ¤å½æ°ä½ä¸ºæµ®ç¹å¼è¿åï¼ï¼å
¶ä¸ r æ¯ FLT_RADIX ãè¥ arg ä¸ºéæ£è§ï¼åå½åå®å¦åå·²æ£è§åã
åæ°
| arg | - | æµ®ç¹å¼ |
è¿åå¼
è¥ä¸åºç°é误ï¼åè¿åä½ä¸ºæç¬¦å·æµ®ç¹å¼ç arg çæ åææ°ã
è¥åºç°å®ä¹åé误ï¼åè¿åå®ç°å®ä¹å¼ã
è¥åºç°æç¹é误ï¼åè¿å -HUGE_VAL ã -HUGE_VALF æ -HUGE_VALL ã
é误å¤ç
æ¥å math_errhandling 䏿å®çé误ã
è¥ arg 为é¶åå¯è½åºç°å®ä¹åæå¼åé误ã
è¥å®ç°æ¯æ IEEE æµ®ç¹ç®æ¯ï¼ IEC 60559 ï¼ï¼å
- è¥
arg为 ±0 ï¼åè¿å -â å¹¶å¼å FE_DIVBYZERO ã - è¥
arg为 ±â ï¼åè¿å +â ã - è¥
arg为 NaN ï¼åè¿å NaN ã - ææå ¶ä»æ åµä¸ï¼ç»ææ¯åç¡®çï¼å³ä¸å¼å FE_INEXACT ï¼ä¸å¿½ç¥å½åèå ¥æ¨¡å¼ã
注æ
POSIX è¦æ±è¥ arg 为 ±0 ååºç°æç¹é误ã
std::logb æè¿åçææ°å¼å§ç»æ¯ std::frexp æè¿åçå° 1 ï¼å 为ä¸åçæ£è§åè¦æ±ï¼å¯¹äº logb è¿åçææ° e ï¼ |arg*r-e
| å¨ 1 ä¸ r ä¹é´ï¼å
¸åå°å¨ 1 ä¸ 2 ä¹é´ï¼ï¼ä½ frexp è¿åçææ° e ï¼ |arg*2-e
| å¨ 0.5 ä¸ 1 ä¹é´ã
示ä¾
æ¯è¾ä¸åçæµ®ç¹åè§£å½æ°
#include <iostream> #include <cmath> #include <limits> #include <cfenv> #pragma STDC FENV_ACCESS ON int main() { double f = 123.45; std::cout << "Given the number " << f << " or " << std::hexfloat << f << std::defaultfloat << " in hex,\n";  double f3; double f2 = std::modf(f, &f3); std::cout << "modf() makes " << f3 << " + " << f2 << '\n';  int i; f2 = std::frexp(f, &i); std::cout << "frexp() makes " << f2 << " * 2^" << i << '\n';  i = std::ilogb(f); std::cout << "logb()/ilogb() make " << f/std::scalbn(1.0, i) << " * " << std::numeric_limits<double>::radix << "^" << std::ilogb(f) << '\n';  // é误å¤ç std::feclearexcept(FE_ALL_EXCEPT); std::cout << "logb(0) = " << std::logb(0) << '\n'; if (std::fetestexcept(FE_DIVBYZERO)) std::cout << " FE_DIVBYZERO raised\n"; }
å¯è½çè¾åºï¼
Given the number 123.45 or 0x1.edccccccccccdp+6 in hex,
modf() makes 123 + 0.45
frexp() makes 0.964453 * 2^7
logb()/ilogb() make 1.92891 * 2^6
logb(0) = -Inf
FE_DIVBYZERO raisedåé
| (C++11)(C++11) |
å°æ°åè§£ä¸ºæææ°åå 2 ç广¬¡ (彿°) |
| (C++11)(C++11)(C++11) |
æåæ°çææ° (彿°) |
| (C++11)(C++11)(C++11)(C++11)(C++11)(C++11) |
å°æ°ä¹ä»¥ FLT_RADIX ç广¬¡ (彿°) |