Calculates the natural logarithm (base e, or approximately 2.71828) of a given value.
Remarks and Examples
Calculates the natural logarithm (base e, or approximately 2.71828) of a given value. In other words, LOG(a) returns the value of ln a.
The argument value may be an integer or floating-point value. The result returned is a floating-point value.
PRINT LOG(1) 0.0 PRINT LOG(10.0) 2.302585092994046 PRINT LOG(EXP(1)) 1.0
ReadyBASIC's internal implementation of the LOG function makes use of the Math.log() function of Java. This function can thus return numeric representations that do not entirely match the way that numeric values usually work in BASIC implementations. In particular, if the argument supplied to LOG is 0, the value of "negative infinity" will be returned, and if the argument supplied to LOG is less than 0, "NaN" ("not a number") will be returned:
PRINT LOG(0) -Infinity PRINT LOG(-5) NaN
There is no way to directly represent these values in ReadyBASIC, although you can use the LOG function to generate these values and you can assign them to variables. Comparison evaluations are not guaranteed to consider two NaN or negative infinity values to be equal, however:
100 NOTANUMBER = LOG(-5) 110 IF LOG(-7) = NOTANUMBER THEN 120 PRINT "Yes" 130 ELSE 140 PRINT "NO" 150 END IF RUN No
See also: EXP
Copyright 2006-2012, Kevin Matz, All Rights Reserved.