Swift Tutorial Swift References

Swift - sinh() Function



The Swift sinh() function returns hyperbolic sine of a value. The hyperbolic sine of x is defined as:

sinh

where e is an Euler's number.

Syntax

In Foundation framework, it is defined as follows:

public func sinh(_ x: CGFloat) -> CGFloat
public func sinh(_ x: Float) -> Float
public func sinh(_ x: Float80) -> Float80
public func sinh(_ __x: Double) -> Double

Parameters

x Specify the value.

Return Value

Returns the hyperbolic sine of a value.

Example:

In the example below, sinh() function is used to find out the hyperbolic sine of a value.

import Foundation

print("sinh(-4.0) = \(sinh(-4.0))")
print("sinh(-2.0) = \(sinh(-2.0))")
print("sinh(0.0) = \(sinh(0.0))")
print("sinh(2.0) = \(sinh(2.0))")
print("sinh(4.0) = \(sinh(4.0))")

The output of the above code will be:

sinh(-4.0) = -27.28991719712775
sinh(-2.0) = -3.626860407847019
sinh(0.0) = 0.0
sinh(2.0) = 3.626860407847019
sinh(4.0) = 27.28991719712775

❮ Swift Math Functions