[comp.sys.ibm.pc.programmer] How to calculate LOG10 in BASIC?

jn@eva.slu.se (Jan Nilsson) (06/14/90)

Hello programmers!

Sorry to disturb You with a (I don't know if I dare say it..) BASIC
question. I want to calculate the common logarithm (LOG10) and BASIC 
only support LOG, the natural logarithm. Could it be calculated in 
another way?

Thanks

Janne 
----------------------------------------------------------------------
Jan Nilsson			Phone: +46 511 30214    
System Manager			Fax:   +46 511 30134   
Dept of Animal Hygiene		Mail:  Jan.Nilsson@Eva.SLU.se	
Swedish University of 			       
Agricultural Sciences		       
P.O.B. 345			"Who?? Me??!!
S-532 24 SKARA			 I no nuthing!!??"
SWEDEN				Manuel, Fawlty Tower
----------------------------------------------------------------------

kdq@demott.COM (Kevin D. Quitt) (06/15/90)

In article <7196.267754e0@eva.slu.se> jn@eva.slu.se (Jan Nilsson) writes:
>Hello programmers!
>
>Sorry to disturb You with a (I don't know if I dare say it..) BASIC
>question. I want to calculate the common logarithm (LOG10) and BASIC 
>only support LOG, the natural logarithm. Could it be calculated in 
>another way?
>

    Nothin' to do with BASIC.  All you need is a magic number:

0.4342944818 (log10 of e)

now, since the log10 of a = log10 of e * ln of a

et voila!


-- 
 _
Kevin D. Quitt         Manager, Software Development    34 12 N  118 27 W
DeMott Electronics Co. 14707 Keswick St.   Van Nuys, CA 91405-1266
VOICE (818) 988-4975   FAX (818) 997-1190  
MODEM (818) 997-4496 Telebit PEP last      demott!kdq   kdq@demott.com

      96.37% of the statistics used in arguments are made up.

mathrich@mthvax.cs.miami.edu (Rich Winkel) (06/15/90)

In <7196.267754e0@eva.slu.se> jn@eva.slu.se (Jan Nilsson) writes:
>Hello programmers!
>Sorry to disturb You with a (I don't know if I dare say it..) BASIC
>question. I want to calculate the common logarithm (LOG10) and BASIC 
>only support LOG, the natural logarithm. Could it be calculated in 
>another way?

Divide by the natural log of 10 (2.30258) to get the common log.

Rich

mms00786@uxa.cso.uiuc.edu (06/15/90)

Simple:

LOG10 x = LOG X / LOG 10

where LOG10 is the log base 10, and LOG is the natural log.
You can store LOG 10 = 2.303 as a constant, then everytime you need
LOG10, simply take the LOG and divide by that constant.

Milan