一些数字疯狂

最近,我为标准数学运算(+,-,*,/)编写了一些辅助函数,以处理没有延迟的统计信息,因此不需要显式转换数字

Caused by: java.lang.ClassnotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.myapplication-1/base.apk"],nativelibraryDirectories=[/data/app/com.example.myapplication-1/lib/x86,/system/lib,/vendor/lib]]

它工作起来很轻松,直到我发现除法运算符的一些错误行为,即:

Double(8)/Double(3) // can be written as 8/3

我是否缺少某些东西,或者可能是一个错误?

wazwsx 回答:一些数字疯狂

我对操作数的位置有点不了解。有效代码为:

func / <F: BinaryFloatingPoint,I: BinaryInteger>(lhs: F,rhs: I) -> F {
    return lhs / F(rhs)
}
func / <F: BinaryFloatingPoint,I: BinaryInteger>(lhs: I,rhs: F) -> F {
    return F(lhs) / rhs
}
let a = 10.0
let b: UInt8 = 8

print(a/b) //1.25
print(b/a) //0.8
本文链接:https://www.f2er.com/3134062.html

大家都在问