Autor Beitrag
Fabian
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: Fr 26.07.02 16:02 
Hallo,
Wie kann ich den Logarithmus einer Zahl berechnen ?
hitstec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 295



BeitragVerfasst: Fr 26.07.02 17:35 
Einfach

ausblenden Quelltext
1:
uses ... System;					

und

ausblenden Quelltext
1:
LN(123.456);					

Das ist der natürliche Logarithmus mit Basis e. Den 10er-Logarithmus kann man daraus ableiten.

PS: In der Delphi-Hilfe stehts auch drin.
Fabian Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: Fr 26.07.02 19:51 
Danke funktioniert ohne Probleme

Aber wie kann ich denn 10er Logarithmus aus dem natürlichen Logarithmus ableiten ?
hitstec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 295



BeitragVerfasst: Fr 26.07.02 20:10 
Die allgemeine Gleichung zum Umrechnen des Logarithmus heißt:

loga(x) = logb(x) / logb(a)

In unserem speziellen Fall also:

log(x) = ln(x) / ln(10)

Als Delphi-Code:

ausblenden Quelltext
1:
2:
3:
4:
function ZehnerLog(x: Real): Real;
begin
  result:=ln(x) / ln(10);
end;

Ausgabe:

ausblenden Quelltext
1:
ShowMessage(Format('%f',[ZehnerLog(10)]));					
b.brecht
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 27.07.02 01:08 
Oder machs so:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
uses Math;

...

function log(x,basis : real):real;
begin
Result:=log10(x) / log10(basis);
end;