Re: 4GL squareroot function needed
Posted in 1999
Here is something you can try. It is pure 4GL and will come as close as the sqrt function of SQL. function sqroot(Mnumber) define Mnumber,Msqrt,Mdivisor,Mdiv2,Moldsqrt float if Mnumber=0 then return 0 end if let Msqrt=1 let Moldsqrt=1 let Mdivisor=2 while Msqrt*Msqrt<>Mnumber let Mdiv2=Mnumber/Mdivisor let Mdivisor=(Mdivisor+Mdiv2)/2 let Msqrt=Mdivisor if Msqrt=Moldsqrt then exit while else let Moldsqrt=Msqrt end if end while return Msqrt end function HTH Joe ------------------------------------------------------------------------- Joseph Cullipher <joseph@cannonexpress.com> Standard Disclaimers Apply ------------------------------------------------------------------------- On Fri, 26 Mar 1999, jrowland1 wrote: > Looking for a function to calculate the square root of a number to > use in a 4Gl function. Currently running 4GL version 6.05. > Thanks > -- > Posted via Talkway - http://www.talkway.com > Surf Usenet at home, on the road, and by email -- always at Talkway. >