Home > lang > log 
 fr de es it nl pl pt pt_BR mk sq ca ar fa vi ja ru zh zh_TW eo
Previous  Next  Edit  Rename  Undo  Refresh  Search  Administration  
Documentation
History
 
Log
Syntax
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.

Note : 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

MessageDescription
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

Logarithms & Exponentials Functions