home *** CD-ROM | disk | FTP | other *** search
- /*********
- *
- * LOGNBASX.C
- *
- * by Ralph Davis
- *
- * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
- *
- * Syntax: LOGNBASX( <expN1>, <expN2> )
- * Return: The log of <expN1> to the base <expN2>
- * if both <expN1> and <expN2> >= 0
- * INFINITY() if either is negative
- *********/
-
- #include "trlib.h"
-
- TRTYPE lognbasx()
- {
- double n1, n2, ret;
-
- if ( PCOUNT == 2 && ISNUM(1) && ISNUM(2) )
- {
- n1 = _parnd(1);
- n2 = _parnd(2);
-
- if ( n1 < 0 || n2 <= 0 ) /* No negatives, and n2 cannot
- be 0 */
- _retnd(_tr_infinity());
- else
- {
- /* Log of n1 to the base n2 = Log(n1) divided by Log(n2) */
-
- ret = _tr_log(n1) / _tr_log(n2);
- _retnd( ret );
- }
- }
- else
- _retnd(ERRORNEG); /* -1 if error */
- }
-