1. RE: Maths Functions
- Posted by Structural D-zine <structuraldzine at hotmail.com> Jul 25, 2001
- 333 views
Thanks, in the meantime I tried writing my own. This will round up, down, towards zero, or away from zero. To accomplish this last use "variable" as "DirFlag". Any advice on improving coding will be appreciated. I couldn't find "!=" documented anywhere but found it appears to work as "not equal to". Is this correct? function Roundout(atom variable,integer DecPlaces,atom DirFlag) --Variable=variable to be rounded --intDecPlaces=round to no of dec places to the right of the decimal -- point if positive; to the left if negative. Integer required --DirFlag 0=round towards zero -- +ve=round to next highest number -- -ve=round to next lowest number end if if DirFlag>0 then --round up var=floor(var+1) end if if DirFlag=0 then --round towards zero sign=1 if var<0 then var=var*-1 --absolute value sign=-1 --sign of var end if var=floor(var)*sign --round down and restore sign end if end if return var/power(10,DecPlaces) --correct decimal places end function Derek Parnell wrote: > Hi Chris, > > try these.... > > function RoundDown(atom a) > return floor(a) > end function > > function RoundUp(atom a) > if integer(a) then > return a > else > return floor(a + 1) > end if > end function > > function Round(atom a, integer places) > return floor(a * power(10, places) + 0.5) * power(10, -places) > end function > > ----- Original Message ----- > From: "Structural D-zine" <structuraldzine at hotmail.com> > To: "EUforum" <EUforum at topica.com> > Sent: Friday, July 20, 2001 7:51 PM > Subject: Maths Functions > > > I have been looking for maths functions equivalent to the Basic > > Round(x,no of places) > > RoundUp > > RoundDown > > > > > Regards, Chris
2. RE: Maths Functions
- Posted by Structural D-zine <structuraldzine at hotmail.com> Jul 25, 2001
- 322 views
"The relational operators < > <= >= = != each produce a 1 (true) or a 0 (false) result. 1 > 0 -- 1 (true) 1 = 1 -- 1 (true) 4.4 >= 4.5 -- 0 (false)" This extract does not actually say what "!=" does. Is it "not equal to"? irvm at ellijay.com wrote: > On Wednesday 25 July 2001 07:23, Structural D-zine wrote: > > > I couldn't find "!=" documented anywhere but found it appears to work as > > "not equal to". Is this correct? > > See Refman2.html. > > Regards, > Irv > > Regards, Chris