From 028999d665ba7fe9616a840e596d58b909dbc01d Mon Sep 17 00:00:00 2001 From: Stuart Mosquera Date: Thu, 11 Dec 2025 15:32:02 -0300 Subject: [PATCH 1/2] Create log.md --- .../concepts/math-functions/terms/log/log.md | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 content/c-sharp/concepts/math-functions/terms/log/log.md diff --git a/content/c-sharp/concepts/math-functions/terms/log/log.md b/content/c-sharp/concepts/math-functions/terms/log/log.md new file mode 100644 index 00000000000..8712dcb68f0 --- /dev/null +++ b/content/c-sharp/concepts/math-functions/terms/log/log.md @@ -0,0 +1,84 @@ +--- +Title: '.Log()' +Description: 'Returns the logarithm of a specified real number.' +Subjects: + - 'Code Foundations' + - 'Computer Science' +Tags: + - 'Arithmetic' + - 'Method' + - 'Numbers' +CatalogContent: + - 'learn-c-sharp' + - 'paths/computer-science' +--- + +The **`Math.Log()`** is a static method that returns the logarithm of a specified real number. + +## Syntax + +```pseudo +Math.Log(value); + +Math.Log(value, newBase); +``` + +**Parameters:** + +- `value`: The real number whose logarithm is to be found. It must be greater than 0. +- `newBase`: The base of the logarithm. + +**Return value:** + +Returns the logarithm of a specified real number. + +> **Note**: If parameter `newBase` isn't specified, it returns the natural (base e) logarithm of the specified real number. + +## Example 1 + +The following example demonstrates the `Math.Log()` method and writes the result to the console. + +```cs +using System; + +class Program +{ + static void Main() + { + double num = 2.0; + double result = Math.Log(num); + Console.WriteLine(result); + } +} +``` + +The example will result in the following output: + +```shell +0.693147180559945 +``` + +## Example 2 + +In this example, the `Math.Log()` method is used the get the logarithm of 100 using 10 as the base, and then, it writes the result to the console. + +```cs +using System; + +class Program +{ + static void Main() + { + double num = 100; + double newBase = 10; + double result = Math.Log(num, newBase); + Console.WriteLine(result); + } +} +``` + +The example will result in the following output: + +```shell +2 +``` From 066490665253e51907185894366edacd5b181cb0 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Sat, 13 Dec 2025 10:24:40 +0530 Subject: [PATCH 2/2] Enhance Log() documentation with detailed descriptions Updated the log.md file to clarify the Log() method's functionality and parameters. --- .../concepts/math-functions/terms/log/log.md | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/content/c-sharp/concepts/math-functions/terms/log/log.md b/content/c-sharp/concepts/math-functions/terms/log/log.md index 8712dcb68f0..2401d9b16da 100644 --- a/content/c-sharp/concepts/math-functions/terms/log/log.md +++ b/content/c-sharp/concepts/math-functions/terms/log/log.md @@ -1,6 +1,6 @@ --- -Title: '.Log()' -Description: 'Returns the logarithm of a specified real number.' +Title: 'Log()' +Description: 'Returns the logarithm of a specified real number, using base e or a specified base.' Subjects: - 'Code Foundations' - 'Computer Science' @@ -13,30 +13,28 @@ CatalogContent: - 'paths/computer-science' --- -The **`Math.Log()`** is a static method that returns the logarithm of a specified real number. +The **`Math.Log()`** is a static method that returns the logarithm of a specified real number. By default, it calculates the natural logarithm (base e), but it can also compute logarithms using a specified base. ## Syntax ```pseudo -Math.Log(value); - -Math.Log(value, newBase); +Math.Log(value, baseValue) ``` **Parameters:** -- `value`: The real number whose logarithm is to be found. It must be greater than 0. -- `newBase`: The base of the logarithm. +- `value` (double): The real number whose logarithm is to be found. It must be greater than 0. +- `baseValue` (double, optional): The base of the logarithm. **Return value:** Returns the logarithm of a specified real number. -> **Note**: If parameter `newBase` isn't specified, it returns the natural (base e) logarithm of the specified real number. +> **Note**: If parameter `baseValue` isn't specified, `Math.Log()` returns the natural (base e) logarithm of the specified real number. ## Example 1 -The following example demonstrates the `Math.Log()` method and writes the result to the console. +The following example demonstrates the `Math.Log()` method and writes the result to the console: ```cs using System; @@ -58,11 +56,11 @@ The example will result in the following output: 0.693147180559945 ``` -## Example 2 +## Codebyte Example -In this example, the `Math.Log()` method is used the get the logarithm of 100 using 10 as the base, and then, it writes the result to the console. +In this example, the `Math.Log()` method is used to get the logarithm of 100 using 10 as the base, and then, it writes the result to the console: -```cs +```codebyte/csharp using System; class Program @@ -76,9 +74,3 @@ class Program } } ``` - -The example will result in the following output: - -```shell -2 -```