TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Rob Basler
from: Graeme Blackley
date: 1994-11-19 05:37:36
subject: Need sqrt() algorithm

Here's the one I use. Hope it helps.

static unsigned long rodent(unsigned long v)
{
    register long t = 1L<<30, r = 0, s;
#define STEP(k) s = t + r; r >>= 1; if (s <= v) { v -= s; r |= t;}

    STEP(15);   t >>= 2;
    STEP(14);   t >>= 2;
    STEP(13);   t >>= 2;
    STEP(12);   t >>= 2;
    STEP(11);   t >>= 2;
    STEP(10);   t >>= 2;
    STEP(9);    t >>= 2;
    STEP(8);    t >>= 2;
    STEP(7);    t >>= 2;
    STEP(6);    t >>= 2;
    STEP(5);    t >>= 2;
    STEP(4);    t >>= 2;
    STEP(3);    t >>= 2;
    STEP(2);    t >>= 2;
    STEP(1);    t >>= 2;
    STEP(0);
     if (r * Origin: The Cave/2, Wellington, New Zealand (3:771/130)
SEEN-BY: 12/2442 54/54 620/243 622/407 623/630 624/50 632/339 348 640/715 820
SEEN-BY: 670/215 690/347 660 700/31 711/409 410 413 430 807 808 809 934 942
SEEN-BY: 711/949 712/353 623 713/888 770/115 771/130 160 270 330 1320 772/1
SEEN-BY: 772/20 135 140 207 350 380 555 774/605 800/1
@PATH: 771/130 1320 772/20 712/353 711/409 54/54 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.