Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
decsqrt.c | 2020-05-11 | 2.4 kB | |
i4glsqrt.c | 2020-05-11 | 603 Bytes | |
readme.txt | 2020-05-11 | 1.3 kB | |
Totals: 3 Items | 4.3 kB | 0 |
Subject: square root From: johnl@informix.com (Jonathan Leffler) Newsgroups: comp.databases.informix Date: 9 Oct 1996 10:03:20 -0400 For SQRT, you could use the i4gl_sqrt() function and the underlying decsqrt() function in the attached shell archive. Note that this code uses DECIMAL types throughout and is therefore accurate up to 32 digits. For general trig, you could consider using the functions in the SELECT statement: SELECT SIN(3.1415) FROM SysTables WHERE Tabid = 1; but (a) that is a ludicrously slow way to do it, and (b) it almost certainly uses the C math library functions, rather than any more precise DECIMAL code, so the accuracy will not exceed about 14 digits. You can get those functions to exececute more quickly by using simple interface functions like i4gl_sin(): #include <math.h> #include <fglsys.h> int i4gl_sin(int n) { double x; if (n != 1) fgl_fatal("i4gl_sin()", 1, -1318); popdub(&x); retdub(sin(x)); return(1); } If you are using an old version of I4GL, you may not have fglsys.h to declare the functions like popdub() and retdub() -- it is then simplest to omit the #include <fglsys.h> line. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> >Does anyone know how to compute square root on 4GL? Also how to compute >logarithmic and trig functions?