[comp.lang.pascal] how can I get a log of a number?

webb@uhccux.uhcc.Hawaii.Edu (Thomas Webb) (12/16/90)

I know that this must be a simple thing to do, but I can't think of a
decent way to get a log base 10 of a number.  Since a log function
isn't included in Pascal (even turbo) I assume it is a simple matter
to derive one for the mathmatically inclined;  not so for me.  Any
help will be much appreciated.

Thanks, 

-tom.
-- 
===============================================================================
webb@uhccux.uhcc.Hawaii.edu  "The first duty in life is to assume a pose.
                              What the second is, no one has yet
					discovered."            -Oscar Wilde

dslg0849@uxa.cso.uiuc.edu (Daniel S. Lewart) (12/16/90)

webb@uhccux.uhcc.Hawaii.Edu (Thomas Webb) writes:

> I know that this must be a simple thing to do, but I can't think of a
> decent way to get a log base 10 of a number.  Since a log function
> isn't included in Pascal (even turbo) I assume it is a simple matter
> to derive one for the mathmatically inclined;  not so for me.  Any
> help will be much appreciated.

function Log(x: Real): Real;
begin
  Log := Ln(x)/Ln(10);
end;

Daniel Lewart
d-lewart@uiuc.edu

johnm@cory.Berkeley.EDU (John D. Mitchell) (12/17/90)

In article <10684@uhccux.uhcc.Hawaii.Edu> webb@uhccux.UUCP (Thomas Webb) writes:

>I know that this must be a simple thing to do, but I can't think of a
>decent way to get a log base 10 of a number.  Since a log function

log base b of x = ln(x) / ln (b)

Good luck,
	John D. Mitchell
	johnm@cory.Berkeley.EDU

kamal@wpi.WPI.EDU (Kamal Z Zamli) (12/17/90)

In article <10684@uhccux.uhcc.Hawaii.Edu> webb@uhccux.UUCP (Thomas Webb) writes:
>
>I know that this must be a simple thing to do, but I can't think of a
>decent way to get a log base 10 of a number.  Since a log function
>isn't included in Pascal (even turbo) I assume it is a simple matter
>to derive one for the mathmatically inclined;  not so for me.  Any
>help will be much appreciated.
>
>Thanks, 
>
>-tom.


Remember the old days of high school, the property of log functions (what
ever base 2,8 etc ).......

function logbase10 (anynumber:real):real;

 begin
  logbase10:=ln(anynmuber)/ln (10);
 end;

Also, you might consider declaring anynumber and functionm logbase10 as
extended just to make sure this function will have wide range.