Trusted answers to developer questions

What is Math.Log10() in C#?

Get Started With Data Science

Learn the fundamentals of Data Science with this free course. Future-proof your career by adding Data Science skills to your toolkit — or prepare to land a job in AI, Machine Learning, or Data Analysis.

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

c#
log10
math
Did you find this helpful?