C# Log10()
Anonymous contributor
Published Feb 11, 2026
In C#, the Math.Log10() method calculates the base-10 logarithm of a given number. This logarithm represents the power to which 10 must be raised to obtain the input value. The method is defined in the System namespace.
Syntax
Math.Log10(number);
Parameters:
number: Adoublevalue whose base-10 logarithm is computed.
Return value:
Returns a double that represents the base-10 logarithm of number.
Return values for different inputs:
- If the input is a positive number, the method returns its base-10 logarithm.
- If the input is
0, the method returnsNegativeInfinity. - If the input is a negative number, the method returns
NaN. - If the input is
NaN, the method returnsNaN. - If the input is
PositiveInfinity, the method returnsPositiveInfinity. - If the input is
NegativeInfinity, the method returnsNaN.
Example
The example below demonstrates the return values of Math.Log10() for different inputs:
using System;class Geeks {public static void Main(String[] args) {double a = 4.55;double b = 0;double c = -2.45;double nan = Double.NaN;double positiveInfinity = Double.PositiveInfinity;double negativeInfinity = Double.NegativeInfinity;Console.WriteLine(Math.Log10(a));Console.WriteLine(Math.Log10(b));Console.WriteLine(Math.Log10(c));Console.WriteLine(Math.Log10(nan));Console.WriteLine(Math.Log10(positiveInfinity));Console.WriteLine(Math.Log10(negativeInfinity));}}
The output of the code is:
0.658011396657112-InfinityNaNNaNInfinityNaN
Codebyte Example
This codebyte example calculates the base-10 logarithm of a given number and prints the result:
All contributors
- Anonymous contributor
Learn C# on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn Microsoft's popular C# programming language, used to make websites, mobile apps, video games, VR, and more.
- Beginner Friendly.15 hours