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

Re: "ALOG2" ?

David Fanning wrote:
[..about the tricky solution alog(x)/alog(2.0) instead
   of writing a DLM...]
> MUCH more billable and difficult! Are you looking for 
> a job? I like your style. :-)

Uh - blush :-)

One rule among my friends is "never try to explain when someone
else has decided you've done a blunder - you're only gonna make
it worse" :-)

Well, actually, the expression is "ikke prøv å ro deg vekk,
det blir bare verre" :-)

But nevertheless, I would like to say in my "defence" that when
such a question comes from Amara Graps, I don't expect the
solution to be trivial!

And she did ask for something that works like the C functions
logb and frexp, which don't actually compute the log in base 2!

logb() returns the integer part of log2 (but as a float/double,
to enable signalling of +/-infinity), whilst frexp(a,i) sets i
to logb(a)+1 and returns a/2^i...

Not that I expect anyone to go for this line of defence... :-)

But I did learn something valuable about writing DLM's: Forget
the IDL_EzCall() routine for processing parameters.

You're much better off doing whatever is necessary (like
ensuring the data is of the correct type/dimensionality etc)
"manually" through the IDL_ENSURE_xxx/IDL_EXCLUDE_xxx macros,
instead of spending an endless amount of time trying to figure
out exactly what goes on inside IDL_EzCall...

This is much like the CW_PDMENU discussion we had a while ago,
only worse.  And do watch out for problems with recursive
routines if you're using the IDL_EzCall routine!!

And I just found out how to create a named variable inside
a DLM: Use the IDL_FindNamedVariable routine.

Well hidden functionality, if you ask me! Most users would
search for something along the lines of "IDL_Make..." or
"IDL_Get...." like I did for quite a while...

Stein Vidar