Skip to content

Commit 126cdc2

Browse files
authored
Fix functions (#8)
1 parent 71bc25e commit 126cdc2

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

Sources/FirebladeMath/Functions/sqrt.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ import Glibc
1313
/// If a domain error occurs, an implementation-defined value is returned (NaN where supported).
1414
/// If a range error occurs due to underflow, the correct result (after rounding) is returned.
1515
public func sqrt(_ float: Float) -> Float {
16-
sqrtf(float)
16+
#if FRB_MATH_DARWIN
17+
return Darwin.sqrtf(float)
18+
#endif
19+
20+
#if FRB_MATH_GLIBC
21+
return Glibc.sqrtf(float)
22+
#endif
1723
}
1824

1925
/// Computes square root of arg.

Sources/FirebladeMath/Functions/tan.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ import Glibc
1313
/// If a domain error occurs, an implementation-defined value is returned (NaN where supported).
1414
/// If a range error occurs due to underflow, the correct result (after rounding) is returned.
1515
public func tan(_ angleRad: Float) -> Float {
16-
tanf(angleRad)
16+
#if FRB_MATH_DARWIN
17+
return Darwin.tanf(angleRad)
18+
#endif
19+
20+
#if FRB_MATH_GLIBC
21+
return Glibc.tanf(angleRad)
22+
#endif
1723
}
1824

1925
/// Computes the tangent of arg (measured in radians).

Sources/FirebladeMath/Functions/tanh.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ import Glibc
1212
/// - Returns: If no errors occur, the hyperbolic tangent of arg (tanh(arg), or (e^arg*-e^-arg)/(e^arg*+e^-arg)) is returned.
1313
/// If a range error occurs due to underflow, the correct result (after rounding) is returned.
1414
public func tanh(_ float: Float) -> Float {
15-
tanhf(float)
15+
#if FRB_MATH_DARWIN
16+
return Darwin.tanhf(float)
17+
#endif
18+
19+
#if FRB_MATH_GLIBC
20+
return Glibc.tanhf(float)
21+
#endif
1622
}
1723

1824
/// Computes the hyperbolic tangent of arg.

0 commit comments

Comments
 (0)