DelphiBasics
Ln
Function
Gives the natural logarithm of a number System unit
 function Ln(Number Extended):Extended;
Description
The Ln function takes an integer or floating point Number and gives the natural logarithm of that number.
 
This is only used for mathematical processing.
 
Ln has the opposite effect to Exp - the exponent of a number. (2.72 raised to that number power).
Related commands
ExpGives the exponent of a number
Log10Gives the log to base 10 of a number
 Download this web site as a Windows program.




 
Example code : Calculate the exponent of 2 and the natural log of the result
var
  float : Double;
begin
  // Get the natural logarithm of 2
  float := Ln(2);

  // Show this value
  ShowMessage('Ln(2) = '+FloatToStr(float));

  // Get the exponent of this value - reverses the Ln operation
  float := Exp(float);

  // Show this value
  ShowMessage('Exp(Ln(2)) = '+FloatToStr(float));
end;
Show full unit code
  Ln(2) = 0.693147180559945
  Exp(Ln(2)) = 2
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page