mirror of
https://github.com/twostraws/Brisk.git
synced 2024-09-11 10:35:25 +03:00
Update Numeric.swift
// ------------------------------------------ // How to replicate the ** operator in Swift //
This commit is contained in:
parent
3701c108fd
commit
bacb79f610
@ -39,3 +39,25 @@ func /<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: I, rhs: F) -> F {
|
||||
func /<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: F, rhs: I) -> F {
|
||||
return lhs / F(rhs)
|
||||
}
|
||||
|
||||
// ------------------------------------------
|
||||
// How to replicate the ** operator in Swift
|
||||
//
|
||||
|
||||
infix operator **
|
||||
|
||||
func **<I: BinaryInteger>(lhs: I, rhs: I) -> I {
|
||||
return I(pow(Double(lhs), Double(rhs)))
|
||||
}
|
||||
|
||||
func **<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: I, rhs: F) -> F {
|
||||
return F(pow(Double(lhs),Double(rhs)))
|
||||
}
|
||||
|
||||
func **<I: BinaryInteger, F: BinaryFloatingPoint>(lhs: F, rhs: I) -> F {
|
||||
return F(pow(Double(lhs),Double(rhs)))
|
||||
}
|
||||
|
||||
func **<F: BinaryFloatingPoint>(lhs: F, rhs: F) -> F {
|
||||
return F(pow(Double(lhs),Double(rhs)))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user