[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: One more question
On Mon, 27 Dec 1999, Ben C. wrote:
> vilohidi@mbnet.fi wrote:
> >
> > Came in to my mind, Is there any better way to see if some integer is
> > +- 10 from another integer, than:
> >
> > if((a<b+11) && (a>b-11))
>
> Well, if you're doing this a lot, you could always write an inline/macro
> function to do it, but AFAIK, there's no more efficent way to do it.
c=a-b; if (abs(a)>11)
? Maybe more expensive? I do not know how hard abs is, but then maybe:
c=a-b; if (a<11 && a>-11)
?
Mads
--
Mads Bondo Dydensborg. madsdyd@challenge.dk
Perhaps only a monopolist like Microsoft could get away with selling worse
products each generation -- products focused so narrowly on the least-
technical member of the consumer base that they necessarily sacrifice technical
excellence.
- www.os2hq.com