- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MathF.Log() Method in C# with Examples
The MathF.Log() method in C# is used to return the logarithm of a specified number.
Syntax
Following is the syntax −
public static float Log (float val);
Above, Val is the specified number whose natural (base e) logarithm to be calculated.
Example
Let us now see an example to implement the MathF.Log() method −
using System; public class Demo { public static void Main(){ float val1 = 0.0f; float val2 = 1.0f; Console.WriteLine(MathF.Log(val1)); Console.WriteLine(MathF.Log(val2)); } }
Output
This will produce the following output −
-Infinity 0
Example
Let us now see another example to implement the MathF.Log() method −
using System; public class Demo { public static void Main(){ float val1 = 45.9f; float val2 = -4.35f; Console.WriteLine(MathF.Log(val1)); Console.WriteLine(MathF.Log(val2)); } }
Output
This will produce the following output −
3.826465 NaN
Advertisements
To Continue Learning Please Login
Login with Google