test_constructor.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Python-iBeacon-Scan 作者: NikNitro 项目源码 文件源码
def test_precision():
    f1 = Float("1.01")
    f2 = Float("1.0000000000000000000001")
    for x in [1, 1e-2, 1e-6, 1e-13, 1e-14, 1e-16, 1e-20, 1e-100, 1e-300,
            f1, f2]:
        result = construct_domain([x])
        y = float(result[1][0])
        assert abs(x - y) / x < 1e-14  # Test relative accuracy

    result = construct_domain([f1])
    y = result[1][0]
    assert y-1 > 1e-50

    result = construct_domain([f2])
    y = result[1][0]
    assert y-1 > 1e-50
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号