Re: Decimal exponent (power) in i4gl?
Posted in 1998
Here's a tiny c power function for use with 4gl:
#include <math.h>
#include <stdio.h>
power(nargs)
int nargs;
{
double x,y;
popdub(&y); popdub(&x);
x = pow(x,y);
retdub(&x);
return(1);
}
You have to link it to the 4gl runner (or c4gl program) as the manuals
describe. 4gl usage would be "let z = power(x,y)".
Peter Lancashire wrote:
>
> Manuel A. Daponte Santiago wrote:
> >
> > In i4gl there is the ** operand to raise a number to a power, but it
> > only handles integers (2 ** 2.5 = 4).
> >
> > Does somebody know hot to perform this operation?
> >
> > Thanks in advance
>
> The database engine from version 7.1 can do it (extract from manual):
>
> POW Function
>
> The POW function raises the base to the exponent. This function requires
> two numeric arguments. The return type is FLOAT. The following example
> returns all the information for circles whose areas ( p r 2 ) are less
> than 1,000 square units:
>
> SELECT * FROM circles WHERE (3.1417 * POW(radius,2)) < 1000>
> 4GL (pre 7.?) will probably not recognise this, so you will have to
> PREPARE the statement.
>
> If you don't have 7.1+ then you will have to write a C function to call
> from 4GL. This is not difficult if you know C and read the manual. It's
> slightly trickier for RDS as you have to compile a custom runner.
> --
> Peter Lancashire
> Information Systems Specialist, Bayer plc
> Eastern Way, Bury St Edmunds, Suffolk, IP32 7AH, UK
> Tel: +44-1635-562258, Fax: +44-1635-562281
> ---
> If all else fails, read the instructions AND the release notes.
> All opinions are my own and not those of Bayer plc.
> My Internet plumbing does not allow me to mail and post news together.
> Sorry.
> ---
> Join Infuse, the UK Informix User Group at http://www.infuse.org.uk/
--
----------------------------------------------------------------------
John H. Frantz Power-4gl: Extending Informix-4gl
john@rl.is http://www.rl.is/~john/pow4gl.html