Path: utzoo!yunexus!oz From: oz@yunexus.UUCP (Ozan Yigit) Newsgroups: comp.lang.c Subject: sqroot of a 2**n number ? Message-ID: <1906@yunexus.UUCP> Date: 12 May 89 19:43:30 GMT Article-I.D.: yunexus.1906 Reply-To: oz@yunexus.UUCP (Ozan Yigit) Organization: York U. Communications Research & Development Lines: 16 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@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