Log

Value = Log ( Number AS Float )

Computes natural logarithm of a number i.e. logarithm to base e, where e is an irrational constant approximately equal to 2.71828. The number must be greater than zero. It cannot be negative or zero.

Gambas has built-in functions to calculate base-2 and base-10 logarithm.

To calculate base-n logarithms the following relation can be used: Logn(x) = Log(x) / Log(n)

Errors

Message Description
Mathematical error (19) Number is negative or zero.

Examples

PRINT Log(2.71828)
0.999999327347

DIM i AS INTEGER
FOR i = 1 TO 50 STEP 10
  PRINT i, Log(i)
NEXT
1    0
11   2.397895272798
21   3.044522437723
31   3.433987204485
41   3.713572066704

See also