Log: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
JwellsNB (talk | contribs)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
''This function is for BASIC compatibility. It is not available in pure JavaScript projects.''
Log(''number'')
Log(''number'')


Line 21: Line 23:
   LogN = LOG(Number) / LOG(Base)
   LogN = LOG(Number) / LOG(Base)
End Function
End Function
</pre>
== Example (JavaScript) ==
<pre>
// Log Example
/* Log calculates natural logarithms */
LogN = function(Base, Number) {
  return Math.log(Number) / Math.log(Base);
}
var e;
e = 2.718282;
NSB.Print("Log(1) = " + Math.log(1));
NSB.Print("Log(e) = " + Math.log(e));
NSB.Print("Log10(2) = " + LogN(10, 2));
</pre>
</pre>


Line 54: Line 40:


[[Category:Math]]
[[Category:Math]]
[[Category:BASIC Functions]]

Latest revision as of 15:30, 25 March 2019

This function is for BASIC compatibility. It is not available in pure JavaScript projects.

Log(number)

Description

Log returns a double-precision value equal to the natural logarithm of a number. The required parameter, number, is any numeric expression. The natural logarithm is the base e logarithm; e is approximately equal to 2.718282.

Calculating base-n logarithm of x is achieved by dividing the natural logarithm of x by the natural logarithm of n.

Example (Basic)

Rem Log Example
'Log calculates natural logarithms
Dim e
e = 2.718282
Print "Log(1) = " & Log(1)
Print "Log(e) = " & Log(e)
Print "Log10(2) = " & LogN(10, 2)

Function LogN(Base, Number)
  LogN = LOG(Number) / LOG(Base)
End Function

Output

LOG(1) = 0
LOG(e) = 1
LOG10(2) = 0.30103

Related Items

Exp