Languages
[Edit]
EN

C# / .NET - Math.Log10() method example

0 points
Created by:
Pearl-Hurley
559

The Math.Log10() method returns the logarithm with base 10 of a number. 

using System;

public class Program
{
    public static void Main(string[] args) 
    {
        // Logarithm with base 10:
        //                             x            y
        Console.WriteLine( Math.Log10( 1    ) ); // 0
        Console.WriteLine( Math.Log10( 3    ) ); // 0.47712125471966244
        Console.WriteLine( Math.Log10( 10   ) ); // 1
        Console.WriteLine( Math.Log10( 100  ) ); // 2
        Console.WriteLine( Math.Log10( 1000 ) ); // 3

        Console.WriteLine( Math.Log10( -1        ) ); //  NaN
        Console.WriteLine( Math.Log10(  0        ) ); //  -∞ / -Infinity
        Console.WriteLine( Math.Log10( Double.PositiveInfinity ) ); //  ∞ / +Infinity
    }
}

The Math.Log10() method is presented on the following chart:

Math.Log10(x) function visualization - C# Math Object.
Math.Log10(x) function visualization - C# Math Object.

1. Documentation

Syntax
namespace System
{
    public static class Math
    {
        // ...
        public static double Log10(double x) { ... }
        // ...
    }
}
Parametersx - double value in the range 0 to +Infinity (primitive value).
Result

number value calculated as log_10(x) mathematical function (primitive value).

If x is negative it returns NaN.

If x is equal to 0 it returns -Infinity.

If x is equal to +Infinity it returns -Infinity.

Description

Log10 is a static method that takes one parameter and returns an approximation of the log_10(x) mathematical function (logarithm with base 10). log10 is called a common logarithm.

References

  1. Logarithm - Wikipedia

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

C# / .NET - Math object

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join