Omita

09-01-2005, 05:55 AM

I am posting this because I couldn't find anything in the past on the subject. But in short, Mel can only caculate log(), log10(), and log1p, not some of that other common Log Math operations and I didn't want to use the API. So... below is my little Log2(N) function, I hope it save someone some time.

This is what i needed to make my powers of 2 code.

- Hays //************************************************

// log2(N)

//************************************************

// The log base N of any number, v, can be calulated by log(v)/log(N) where

// the function log can have any base

//

proc float log2( float $variable )

{

return (log ($variable))/(log (2));

}

/*********** Mini-Docs *************

Example:log2(5);

// Result: 2.321928 //

*********************************/

This is what i needed to make my powers of 2 code.

- Hays //************************************************

// log2(N)

//************************************************

// The log base N of any number, v, can be calulated by log(v)/log(N) where

// the function log can have any base

//

proc float log2( float $variable )

{

return (log ($variable))/(log (2));

}

/*********** Mini-Docs *************

Example:log2(5);

// Result: 2.321928 //

*********************************/