From befaac33403b4ed211e87c7e4551dc6f0670dca9 Mon Sep 17 00:00:00 2001 From: NGonzalez-ng Date: Wed, 19 Nov 2025 10:38:33 +0100 Subject: [PATCH 1/4] Add log10.md file --- .../math-functions/terms/log10/log10.md | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 content/c-sharp/concepts/math-functions/terms/log10/log10.md diff --git a/content/c-sharp/concepts/math-functions/terms/log10/log10.md b/content/c-sharp/concepts/math-functions/terms/log10/log10.md new file mode 100644 index 00000000000..ea9f347f5b3 --- /dev/null +++ b/content/c-sharp/concepts/math-functions/terms/log10/log10.md @@ -0,0 +1,118 @@ +--- +Title: 'log10()' +Description: 'Returns the base 10 logarithm of a specified number' +Subjects: + - 'Web Development' + - 'Computer Science' +Tags: + - 'Arithmetic' + - 'Functions' + - 'Math' + - 'Methods' +CatalogContent: + - 'learn-c-sharp' + - 'paths/computer-science' +--- + +In C#, the **Log10()** method is a Math method used to return the base 10 logarithm of a specified number. +The base 10 logarithm (or decimal logarithm) is the continuous function that transforms a product into a sum and whose value is 1 for x = 10. + +## Syntax of C# `Math.Log10() + +```pseudo +Math.Log10(number); +``` + +**Parameters** + +- `number`: the specified number whose logarithm to be calculated and its type is System.Double. + +**Return Value** + +Returns the logarithm of `number`(base 10 log of `number`) and its type is System.Double. +Note: Parameter `number` is always specified as a base 10 number. The return value is depend on the argument passed. +Below are some cases: +- If the argument is positive then method will return the natural logarithm or log10(number). +- If the argument is zero, then the result is NegativeInfinity. +- If the argument is Negative(less than zero) or equal to NaN, then the result is NaN. +- If the argument is PositiveInfinity, then the result is PositiveInfinity. +- If the argument is NegativeInfinity, then the result is NaN. + +## Example + +The following example shows Log10() returns for different possible values: + +```cs +using System; + +class Geeks { + + // Main Method + public static void Main(String[] args) + { + + // double values whose logarithm + // to be calculated + double a = 4.55; + double b = 0; + double c = -2.45; + double nan = Double.NaN; + double positiveInfinity = Double.PositiveInfinity; + double negativeInfinity = Double.NegativeInfinity; + + // Input is positive number so output + // will be logarithm of number + Console.WriteLine(Math.Log10(a)); + + // positive zero as argument, so output + // will be -Infinity + Console.WriteLine(Math.Log10(b)); + + // Input is negative number so output + // will be NaN + Console.WriteLine(Math.Log10(c)); + + // Input is NaN so output + // will be NaN + Console.WriteLine(Math.Log10(nan)); + + // Input is PositiveInfinity so output + // will be Infinity + Console.WriteLine(Math.Log10(positiveInfinity)); + + // Input is NegativeInfinity so output + // will be NaN + Console.WriteLine(Math.Log10(negativeInfinity)); + } +} +``` + +Output of the code: + +```shell +0.658011396657112 +-Infinity +NaN +NaN +Infinity +NaN +``` + +## Codebyte Example (if applicable) + +The following example uses `Math.Log10()` to calculate base 10 logarithm of `x`. The result is stored in the `result` variable. + +```codebyte/csharp +using System; + +class Program +{ + static void Main() + { + double x = 10.0; + double result = Math.Log10(x); + + Console.WriteLine($"The base 10 logarithm of {x} is {result}"); + } +} +``` \ No newline at end of file From 8308163c3072064aab79cc4ec254314c1922a013 Mon Sep 17 00:00:00 2001 From: NGonzalez-ng Date: Wed, 19 Nov 2025 11:00:01 +0100 Subject: [PATCH 2/4] EDIT: Add log10.md with minor corrections --- .../c-sharp/concepts/math-functions/terms/log10/log10.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/c-sharp/concepts/math-functions/terms/log10/log10.md b/content/c-sharp/concepts/math-functions/terms/log10/log10.md index ea9f347f5b3..3175b32b2bf 100644 --- a/content/c-sharp/concepts/math-functions/terms/log10/log10.md +++ b/content/c-sharp/concepts/math-functions/terms/log10/log10.md @@ -17,7 +17,7 @@ CatalogContent: In C#, the **Log10()** method is a Math method used to return the base 10 logarithm of a specified number. The base 10 logarithm (or decimal logarithm) is the continuous function that transforms a product into a sum and whose value is 1 for x = 10. -## Syntax of C# `Math.Log10() +## Syntax of C# `Math.Log10()` ```pseudo Math.Log10(number); @@ -29,7 +29,7 @@ Math.Log10(number); **Return Value** -Returns the logarithm of `number`(base 10 log of `number`) and its type is System.Double. +Returns the logarithm of `number` (base 10 log of `number`) and its type is System.Double. Note: Parameter `number` is always specified as a base 10 number. The return value is depend on the argument passed. Below are some cases: - If the argument is positive then method will return the natural logarithm or log10(number). @@ -115,4 +115,4 @@ class Program Console.WriteLine($"The base 10 logarithm of {x} is {result}"); } } -``` \ No newline at end of file +``` From af92b444450f04cdc3cd94328798100455cde41c Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Thu, 20 Nov 2025 16:00:55 +0530 Subject: [PATCH 3/4] minor content fixes --- .../math-functions/terms/log10/log10.md | 102 +++++++----------- 1 file changed, 38 insertions(+), 64 deletions(-) diff --git a/content/c-sharp/concepts/math-functions/terms/log10/log10.md b/content/c-sharp/concepts/math-functions/terms/log10/log10.md index 3175b32b2bf..2747c93eb83 100644 --- a/content/c-sharp/concepts/math-functions/terms/log10/log10.md +++ b/content/c-sharp/concepts/math-functions/terms/log10/log10.md @@ -1,9 +1,9 @@ --- Title: 'log10()' -Description: 'Returns the base 10 logarithm of a specified number' +Description: 'Returns the base-10 logarithm of a specified number.' Subjects: - - 'Web Development' - 'Computer Science' + - 'Web Development' Tags: - 'Arithmetic' - 'Functions' @@ -14,8 +14,7 @@ CatalogContent: - 'paths/computer-science' --- -In C#, the **Log10()** method is a Math method used to return the base 10 logarithm of a specified number. -The base 10 logarithm (or decimal logarithm) is the continuous function that transforms a product into a sum and whose value is 1 for x = 10. +In C#, the **`Math.Log10()`** method returns 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 of C# `Math.Log10()` @@ -25,69 +24,46 @@ Math.Log10(number); **Parameters** -- `number`: the specified number whose logarithm to be calculated and its type is System.Double. +- `number`: A `double` value whose base-10 logarithm is computed. -**Return Value** +**Return value:** -Returns the logarithm of `number` (base 10 log of `number`) and its type is System.Double. -Note: Parameter `number` is always specified as a base 10 number. The return value is depend on the argument passed. -Below are some cases: -- If the argument is positive then method will return the natural logarithm or log10(number). -- If the argument is zero, then the result is NegativeInfinity. -- If the argument is Negative(less than zero) or equal to NaN, then the result is NaN. -- If the argument is PositiveInfinity, then the result is PositiveInfinity. -- If the argument is NegativeInfinity, then the result is NaN. +Returns a `double` that represents the base-10 logarithm of `number`. Behavior for special inputs: + +- If the input is a positive number, the method returns its base-10 logarithm. +- If the input is zero, the method returns `NegativeInfinity`. +- If the input is a negative number, the method returns `NaN`. +- If the input is `NaN`, the method returns `NaN`. +- If the input is `PositiveInfinity`, the method returns `PositiveInfinity`. +- If the input is `NegativeInfinity`, the method returns NaN. ## Example -The following example shows Log10() returns for different possible values: +The example below demonstrates the return values of `Math.Log10()` for different inputs: ```cs using System; class Geeks { - - // Main Method - public static void Main(String[] args) - { - - // double values whose logarithm - // to be calculated - double a = 4.55; - double b = 0; - double c = -2.45; - double nan = Double.NaN; - double positiveInfinity = Double.PositiveInfinity; - double negativeInfinity = Double.NegativeInfinity; - - // Input is positive number so output - // will be logarithm of number - Console.WriteLine(Math.Log10(a)); - - // positive zero as argument, so output - // will be -Infinity - Console.WriteLine(Math.Log10(b)); - - // Input is negative number so output - // will be NaN - Console.WriteLine(Math.Log10(c)); - - // Input is NaN so output - // will be NaN - Console.WriteLine(Math.Log10(nan)); - - // Input is PositiveInfinity so output - // will be Infinity - Console.WriteLine(Math.Log10(positiveInfinity)); - - // Input is NegativeInfinity so output - // will be NaN - Console.WriteLine(Math.Log10(negativeInfinity)); - } + 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)); + } } ``` -Output of the code: +The output of the code is: ```shell 0.658011396657112 @@ -98,21 +74,19 @@ Infinity NaN ``` -## Codebyte Example (if applicable) +## Codebyte Example -The following example uses `Math.Log10()` to calculate base 10 logarithm of `x`. The result is stored in the `result` variable. +This example calculates the base-10 logarithm of `x` and prints the result: ```codebyte/csharp using System; -class Program -{ - static void Main() - { - double x = 10.0; - double result = Math.Log10(x); +class Program { + static void Main() { + double x = 10.0; + double result = Math.Log10(x); - Console.WriteLine($"The base 10 logarithm of {x} is {result}"); - } + Console.WriteLine($"The base 10 logarithm of {x} is {result}"); + } } ``` From 78030aea06d9b11765d24235172bf69c106bf808 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Thu, 20 Nov 2025 16:01:44 +0530 Subject: [PATCH 4/4] Update log10.md --- content/c-sharp/concepts/math-functions/terms/log10/log10.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/c-sharp/concepts/math-functions/terms/log10/log10.md b/content/c-sharp/concepts/math-functions/terms/log10/log10.md index 2747c93eb83..17096eecc6b 100644 --- a/content/c-sharp/concepts/math-functions/terms/log10/log10.md +++ b/content/c-sharp/concepts/math-functions/terms/log10/log10.md @@ -1,5 +1,5 @@ --- -Title: 'log10()' +Title: 'Log10()' Description: 'Returns the base-10 logarithm of a specified number.' Subjects: - 'Computer Science'