Re: Strange problem
- Posted by Robert Craig <rds at ATTCANADA.NET> Mar 20, 2000
- 483 views
Lewis Townsend writes: > function int_round (atom a) > integer sign sign = 1 > if a < 0 then > sign = -1 > end if > return floor (a + .5 * sign) > end function > > I suppose one could write a recursive version of this to > work with sequences. All you need is: function int_round(object a) return floor(a+0.5) end function This rounds off to the nearest integer. It works for atoms and sequences, negative numbers etc. > I for one would almost rather recieve an error > or a warning than allow subscripts be non-integers. I mainly allowed non-integers because disallowing them would hurt performance slightly. Performance of subscripting is very important to most programs. > My main confusion was that when I print()ed the results of > the expressions it said 1 instead of .9999999999. Is that > because of the 10 digit cutoff? Yes. It *rounds* to 10 digits, but doesn't print trailing 0's. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com