Calculates x = log10 of integer i such that pow(10,x) <= i.
Intop-Log10 | Calculates x = log10 of integer i such that pow(10,x) <= i. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file Intop-Log10. |
C-kern/ | Implementation file Intop-Log10 impl. |
Functions | |
test | |
unittest_math_int_log10 | Tests implementation of log10_int. |
int_t | |
compute | |
log10_int | Returns the logarithm to base 2 as integer of an integer value. |
log10_int32 | Implements log10_int for 32 bit values. |
log10_int64 | Implements log10_int for 64 bit values. |
inline implementation | |
Functions | |
log10_int | Implements int_t.log10_int. |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2012 Jörg Seebohn
Header file Intop-Log10.
Implementation file Intop-Log10 impl.
test | |
unittest_math_int_log10 | Tests implementation of log10_int. |
int unittest_math_int_log10( void )
Tests implementation of log10_int.
compute | |
log10_int | Returns the logarithm to base 2 as integer of an integer value. |
log10_int32 | Implements log10_int for 32 bit values. |
log10_int64 | Implements log10_int for 64 bit values. |
unsigned log10_int( unsigned i )
Returns the logarithm to base 2 as integer of an integer value. This value is the same as the index of the most significant bit.
This function is generic in that it accepts either 32 or 64 bit unsigned integers and selects the corresponding implementation.
Special case: In case the parameter value is 0 the function returns 0.
The returned value is exact if <ispowerof2_int>(i) is true else it is truncated to the next lower int value. The following equation always holds true:
i >= pow(10, log10_int(i))
i | The argument whose logarithm to base 10 is caclulated and returned. |
unsigned log10_int32( uint32_t i )
Implements log10_int for 32 bit values.
unsigned log10_int64( uint64_t i )
Implements log10_int for 64 bit values.
Functions | |
log10_int | Implements int_t.log10_int. |
Implements int_t.log10_int. TODO: reimplement it with _Generic
Tests implementation of log10_int.
int unittest_math_int_log10( void )
Returns the logarithm to base 2 as integer of an integer value.
unsigned log10_int( unsigned i )
Implements log10_int for 32 bit values.
unsigned log10_int32( uint32_t i )
Implements log10_int for 64 bit values.
unsigned log10_int64( uint64_t i )