sqroot of a 2**n number ?
Ozan Yigit
oz at yunexus.UUCP
Sat May 13 05:43:30 AEST 1989
given any number that is an exact power of two, finding the square
root: this can be done by counting to the bit position on some
architectures. Does anyone know of a really portable version of
this, assuming the code below will not work on all architectures ?
(no sqrt call)
if (n > 0) /* n > 0 && n == 2**X */
for (i = 0; !(n & 1); i++)
n >>= 1;
oz
--
use the source, luke !! Usenet: oz at nexus.yorku.ca
uh... we forgot to tell you... ......!uunet!utai!yunexus!oz
it is unintelligible, but hey, you Bitnet: oz@[yulibra|yuyetti]
got it, for free (!). Phonet: +1 416 736-5257x3976
More information about the Comp.lang.c
mailing list