Re: 4gl round function???
Posted in 1997
In article <5jlof5$sak@cssun.mathcs.emory.edu>, joseph@cannonexpress.com (Joseph Cullipher) wrote: > > Hi all, > I am in need of a round function for 4gl. I am currently using 6.00 and > haven't found one in my manuals or release notes. I have found out that > if I use the using clause it will round. > > let smallint=3-(7/4) using "<" > > this seems to work but if I upgrade my 4gl will this stil work? > Is there an undocumented function that I should use instead? Hi Joe, There are very few built in 4gl functions. A rounding function is probably best (most efficient) as a C function, but here's a 4gl function that I use that can round to a variable decimal position. The first parameter is the value to be rounded and the second is the decimal position (zero rounds to an integer). It should work on all versions of 4gl. function round(dval,dpos) define dval decimal, dpos smallint, ival decimal(16,0) let ival = dval * (10 ** dpos) let dval = ival / (10 ** dpos) return dval end function Your example would be: let smallint=round((3-(7/4)),0) ---------------------------------------------------------------------- John H. Frantz Power-4gl: Extending Informix-4gl frantz@centrum.is http://www.rl.is/~john/pow4gl.html -------------------==== Posted via Deja News ====----------------------- http://www.dejanews.com/ Search, Read, Post to Usenet