RE: How to square root in 4gl
Posted in 1997
Yes in fact you can find the Nth root, or the Nth power with the
following code:
let number = n_root(16,2)
display number (gives 4)
let number = n_root(81,4)
display number (gives 3)
Here's the code:
{#######################################################################
#######
PROGRAM: n_root.4gl
DIRECTORY: common
PURPOSE:
HISTORY: 07/12/96 SB Original
########################################################################
#####}
{#######################################################################
#######
PURPOSE: return the nth root of x
can also use 1/n to get powers of x
########################################################################
#####}
function n_root(x, n)
define x float,
n float,
a float,
str char(150)
let str = "select exp((logn(?)/?)) ans",
" from systables where tabname = 'systables' into temp t_root"
prepare s_sel from str
execute s_sel using x, n
select ans into a
from t_root
drop table t_root
return a
end function
Of course standard disclaimers apply...
> -----Original Message-----
> From: catalin_dumitrache@exe.com.au
> [SMTP:catalin_dumitrache@exe.com.au]
> Sent: Wednesday, December 10, 1997 8:36 PM
> To: informix-list@rmy.emory.edu
> Subject: How to square root in 4gl
>
>
> Is there a way to find the square root in 4gl ?
> I do not want to call a C function.
>
> Thanks
> Catalin Dumitrache (EXE Technologies - Melbourne).