Namespaces
Variants
Actions

std::log10, std::log10f, std::log10l

From cppreference.com
< cpp‎ | numeric‎ | math
 
 
 
 
Defined in header <cmath>
(1)
float       log10 ( float num );

double      log10 ( double num );

long double log10 ( long double num );
(until C++23)
/*floating-point-type*/
            log10 ( /*floating-point-type*/ num );
(since C++23)
(constexpr since C++26)
float       log10f( float num );
(2) (since C++11)
(constexpr since C++26)
long double log10l( long double num );
(3) (since C++11)
(constexpr since C++26)
SIMD overload (since C++26)
Defined in header <simd>
template< /*math-floating-point*/ V >

constexpr /*deduced-simd-t*/<V>

            log10 ( const V& v_num );
(S) (since C++26)
Additional overloads (since C++11)
Defined in header <cmath>
template< class Integer >
double      log10 ( Integer num );
(A) (constexpr since C++26)
1-3) Computes the common (base-10) logarithm of num. The library provides overloads of std::log10 for all cv-unqualified floating-point types as the type of the parameter.(since C++23)
S) The SIMD overload performs an element-wise std::log10 on v_num.
(See math-floating-point and deduced-simd-t for their definitions.)
(since C++26)
A) Additional overloads are provided for all integer types, which are treated as double.
(since C++11)

Contents

[edit] Parameters

num - floating-point or integer value

[edit] Return value

If no errors occur, the common (base-10) logarithm of num (log10(num) or lg(num)) is returned.

If a domain error occurs, an implementation-defined value is returned (NaN where supported).

If a pole error occurs, -HUGE_VAL, -HUGE_VALF, or -HUGE_VALL is returned.

[edit] Error handling

Errors are reported as specified in math_errhandling.

Domain error occurs if num is less than zero.

Pole error may occur if num is zero.

If the implementation supports IEEE floating-point arithmetic (IEC 60559),

  • If the argument is ±0, -∞ is returned and FE_DIVBYZERO is raised.
  • If the argument is 1, +0 is returned.
  • If the argument is negative, NaN is returned and