二进制系统上(其中FLT_RADIX为2),std::ldexp等价于std::scalbn。 函数std::ldexp(“加载指数”)与其对偶std::frexp能一同用于操纵浮点数的表示,而无需直接的位操作。 多数实现上,std::ldexp效率低于用通常算术运算符乘或除以二的幂。 示例 #include <iostream>#include <cmath>#include <cerrno>#include <cs...
double ldexp ( Integer num, int exp ); (A) (C++11 起) (C++23 起为 constexpr) 1-3) 将浮点数 num 乘以2 的 exp 次幂。标准库提供所有以无 cv 限定的浮点数类型作为实参 num 的类型的 std::ldexp 重载。(C++23 起)A) 为所有整数类型提供额外重载,将它们当做 double。 (C++11 起)参数...
std::ldexp,std::ldexpf,std::ldexpl C++ Numerics library Common mathematical functions Defined in header<cmath> (1) floatldexp(floatnum,intexp); doubleldexp(doublenum,intexp); longdoubleldexp(longdoublenum,intexp); (until C++23) constexpr/* floating-point-type */ ...
Syntax: #include <math.h> double ldexp( double num, int exp ); The ldexp() function returnsnum* (2 ^exp). And get this: if an overflow occurs,HUGE_VALis returned. Related topics: frexp modf