Computes the square root of an integer number.
Intop-SquareRoot | Computes the square root of an integer number. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file Intop-SquareRoot. |
C-kern/ | Implementation file Intop-SquareRoot impl. |
Functions | |
test | |
unittest_math_int_sqroot | Tests implementation of sqroot_int. |
int_t | |
compute | |
sqroot_int | Returns the square root of an unsigned integer number. |
sqroot_int32 | Returns the square root from an unsigned 32 bit integer. |
sqroot_int64 | Returns the square root from an unsigned 64 bit integer. |
inline implementation | |
Functions | |
sqroot_int | Implements int_t.sqroot_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-SquareRoot.
Implementation file Intop-SquareRoot impl.
test | |
unittest_math_int_sqroot | Tests implementation of sqroot_int. |
int unittest_math_int_sqroot( void )
Tests implementation of sqroot_int.
compute | |
sqroot_int | Returns the square root of an unsigned integer number. |
sqroot_int32 | Returns the square root from an unsigned 32 bit integer. |
sqroot_int64 | Returns the square root from an unsigned 64 bit integer. |
unsigned sqroot_int( unsigned number )
Returns the square root of an unsigned integer number. This function is generic in that it accepts either 32 or 64 bit unsigned integers and selects the corresponding implementation. The returned value has the following property:
number >= sqroot_int(number) * sqroot_int(number) && number < (sqroot_int(number)+1) * (sqroot_int(number)+1)
uint16_t sqroot_int32( uint32_t number )
Returns the square root from an unsigned 32 bit integer. This function is called from sqroot_int.
uint32_t sqroot_int64( uint64_t number )
Returns the square root from an unsigned 64 bit integer. This function is called from sqroot_int.
Functions | |
sqroot_int | Implements int_t.sqroot_int. |
Implements int_t.sqroot_int. Calls sys_sqroot_int64 for a faster implementation of the default implementation sqroot_int64. TODO: reimplement it with _Generic
Tests implementation of sqroot_int.
int unittest_math_int_sqroot( void )
Returns the square root of an unsigned integer number.
unsigned sqroot_int( unsigned number )
Returns the square root from an unsigned 32 bit integer.
uint16_t sqroot_int32( uint32_t number )
Returns the square root from an unsigned 64 bit integer.
uint32_t sqroot_int64( uint64_t number )
Replaces sqroot_int64 with faster sqrtl (long double version).
#define sys_sqroot_int64 sqrtl
Implements the High School Square Root Algorithm for 64 bit unsigned integer.
uint32_t sqroot_int64( uint64_t number )