Microsoft KB Archive/31660

= How to Get Logarithm Base 10 Using LOG(x#)/LOG(10#) in BASIC =

Article ID: 31660

Article Last Modified on 11/21/2006



This article was previously published under Q31660



SUMMARY
Microsoft BASIC offers a LOG function that returns only the natural logarithm, that is, the logarithm to the base e. The number e is a constant approximately equal to 2.718282.

To return a logarithm base b, you can use the following general mathematical formula:

(Log base b of x) = (natural log of x) / (natural log of b)

To return a logarithm base 10, you can use the following specific mathematical formula:

(Log base 10 of x) = (natural log of x) / (natural log of 10)



MORE INFORMATION
The following example defines a Microsoft BASIC single-line function called FNLog10, which returns the logarithm base 10 of a number: DEF FNLog10(x#) = LOG(x#) / LOG(10#) y#=45 PRINT &quot;The logarithm base 10 of y# = &quot;; FNLog10(y#) The above formula applies to any product that supports the natural logarithm (LOG) function, such as the following products:

 For the Apple Macintosh:

 Microsoft QuickBASIC Versions 1.00, 1.00a, 1.00b Microsoft BASIC Compiler Version 1.00 Microsoft BASIC Interpreter Versions 1.00, 1.01, 2.00, 2.10, 3.00  For the IBM PC and compatibles:

 Microsoft BASIC Compiler Versions 5.35 and 5.36 for MS-DOS</li> Microsoft QuickBASIC Versions 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.00b, 4.50 for MS-DOS</li> Microsoft BASIC Compiler Versions 6.00, 6.00b for MS OS/2 and MS-DOS</li> Microsoft BASIC Professional Development System (PDS) Version 7.00, 7.10 for MS OS/2 and MS-DOS</li> Microsoft GW-BASIC Interpreter Versions 3.20, 3.22, and 3.23 for MS-DOS</li></ol> </li></ol>

Additional query words: QuickBas BasicCom MQuickB

Keywords: KB31660

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.