Float80 math function

Hi again!

It seems that there are to different versions of lgamma() with different return types:

lgamma(_ x: Double/Float/Float80) -> (Double/Float/Float80, Int)

and

lgamma(_x: Double/Float/Float80) -> Double/Float/Float80

How can I determine, which version will be used?
I suppose the Int will be used to store the sign of the Gamma function.

I want to have a generic lgamma-version as follows:

internal func lgamma<T: FloatingPoint>(_ x: T) -> T {
    if x.self is Double {
        return lgamma(x as! Double) as! T    /* <- Ambiguous use of 'lgamma' */
    }
    if x.self is Float {
        return lgamma(x as! Float) as! T /
    }
    #if arch(x86_64)
    if x.self is Float80 {
        return lgammal(x as! Float80) as! T
    }
    #endif
    return T.nan
}

Best regards!

strike