mirror of
https://github.com/ETLCPP/etl.git
synced 2026-10-28 18:07:10 +08:00
Changed math log case.
This commit is contained in:
parent
a174038379
commit
d1b0ca47d4
24
math.h
24
math.h
@ -34,19 +34,19 @@ SOFTWARE.
|
|||||||
namespace etl
|
namespace etl
|
||||||
{
|
{
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
/// The base generic Log template.
|
/// The base generic log template.
|
||||||
/// Defines 'value' as the log of the number at the specified base.
|
/// Defines 'value' as the log of the number at the specified base.
|
||||||
/// The result is rounded down to the next integer.
|
/// The result is rounded down to the next integer.
|
||||||
///\tparam N The number to find the log of.
|
///\tparam N The number to find the log of.
|
||||||
///\tparam BASE The base of the log.
|
///\tparam BASE The base of the log.
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
template <const size_t N, const size_t BASE>
|
template <const size_t N, const size_t BASE>
|
||||||
struct Log
|
struct log
|
||||||
{
|
{
|
||||||
enum Value
|
enum value_type
|
||||||
{
|
{
|
||||||
// Recursive definition.
|
// Recursive definition.
|
||||||
value = (N >= BASE) ? 1 + Log<N / BASE, BASE>::value : 0
|
value = (N >= BASE) ? 1 + log<N / BASE, BASE>::value : 0
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -54,9 +54,9 @@ namespace etl
|
|||||||
/// Specialisation for N = 1
|
/// Specialisation for N = 1
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
template <const size_t BASE>
|
template <const size_t BASE>
|
||||||
struct Log<1, BASE>
|
struct log<1, BASE>
|
||||||
{
|
{
|
||||||
enum Value
|
enum value_type
|
||||||
{
|
{
|
||||||
value = 0
|
value = 0
|
||||||
};
|
};
|
||||||
@ -66,9 +66,9 @@ namespace etl
|
|||||||
/// Specialisation for N = 0
|
/// Specialisation for N = 0
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
template <const size_t BASE>
|
template <const size_t BASE>
|
||||||
struct Log<0, BASE>
|
struct log<0, BASE>
|
||||||
{
|
{
|
||||||
enum Value
|
enum value_type
|
||||||
{
|
{
|
||||||
value = 0
|
value = 0
|
||||||
};
|
};
|
||||||
@ -80,9 +80,9 @@ namespace etl
|
|||||||
template <const size_t N>
|
template <const size_t N>
|
||||||
struct Log2
|
struct Log2
|
||||||
{
|
{
|
||||||
enum Value
|
enum value_type
|
||||||
{
|
{
|
||||||
value = Log<N, 2>::value
|
value = log<N, 2>::value
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -92,9 +92,9 @@ namespace etl
|
|||||||
template <const size_t N>
|
template <const size_t N>
|
||||||
struct Log10
|
struct Log10
|
||||||
{
|
{
|
||||||
enum Value
|
enum value_type
|
||||||
{
|
{
|
||||||
value = Log<N, 10>::value
|
value = log<N, 10>::value
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user