a shot of dev knowledge

RELATED TAGS

What is Math.Log10() in C#?

C# has a built-in Math class that provides useful mathematical functions and operations. This class has the Log10() function, which is used to compute the base 10 logarithm of a specified number.

Syntax

public static double Log10 (double value);

Parameters

  • value: This is of the Double type and represents the input value for which we have to find Log10(). Its range is all double numbers.

Return value

  • Double: This returns a positive Double number representing the base 10 log of the value.

  • NaN: This returns an input of negative or NaN in value.

  • PositiveInfinity: This returns an input of PositiveInfinity in value.

  • NegativeInfinity: This returns an input of 0 in value.

value is a base 10 number.

Example

using System;
class Educative
{
    static void Main()
    {
        double result = Math.Log10(20);
        System.Console.WriteLine("Log10(20) = "+ result);

        double result1 = Math.Log10(-20);
        System.Console.WriteLine("Log10(-20) = "+ result1);

        double result2 = Math.Log10(0);
        System.Console.WriteLine("Log10(0) = "+ result2);

        double result3 = Math.Log10(Double.PositiveInfinity);
        System.Console.WriteLine("Log10(∞) = "+ result3);
    }
}

RELATED TAGS

RELATED COURSES

View all Courses

Keep Exploring