Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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.Tanh() Method in C# with Examples
The MathF.Tanh() method in C# returns the hyperbolic tangent of a given single value argument.
Syntax
Following is the syntax −
public static float Tanh (float val);
Above, Val is the is number whose hyperbolic tangent is to be returned.
Example
Let us now see an example to implement the MathF.Tanh() method −
using System;
public class Demo {
public static void Main(){
float val1 = 10f;
float val2 = float.NaN;
Console.WriteLine("MathF.Tanh(val1) = "+MathF.Tanh(val1));
Console.WriteLine("MathF.Tanh(val2) = "+MathF.Tanh(val2));
}
}
Output
This will produce the following output −
MathF.Tanh(val1) = 1 MathF.Tanh(val2) = NaN
Example
Let us now see another example to implement the MathF.Tanh() method −
using System;
public class Demo {
public static void Main(){
float val1 = float.PositiveInfinity;
float val2 = float.NegativeInfinity;
float val3 = (20f * (MathF.PI)) / 180;
Console.WriteLine("MathF.Tanh(val1) = "+MathF.Tanh(val1));
Console.WriteLine("MathF.Tanh(val2) = "+MathF.Tanh(val2));
Console.WriteLine("MathF.Tanh(val3) = "+MathF.Tanh(val3));
}
}
Output
This will produce the following output −
MathF.Tanh(val1) = 1 MathF.Tanh(val2) = -1 MathF.Tanh(val3) = 0.3355469
Advertisements