[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q]: ID analog to FORTRAN "sign" function

Dick Jackson wrote:
> Do I dare offer one more? Subscript lookups seem faster than arithmetic
> operations, making this one faster, more compact and no less cryptic! :-)
>     Return, Abs(a) * ([-1, 1])[b GE 0]

to which I reply:

If this one really works, then why not go even one step further?

Return, ([-Abs(a), Abs(a)])[b GE 0]


Return, ([a, -a])[(a*b) LT 0]

I haven't timed either of these to find out if they're truly better (as
I don't have IDL on my newsgroup computer), but they MIGHT work