与简单的算术失败的合同 [英] Failing contract with simple arithmatic

查看:96
本文介绍了与简单的算术失败的合同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


静态检查是否有理由抛出以下合同的警告:

Is there some reason why the static check throws warnings for the following contract:

            Contract.Ensures(Contract.Result<double>() >= minimumValue);
            Contract.Ensures(Contract.Result<double>() <= maximumValue);

            return minimumValue + (0.5 * (maximumValue - minimumValue);


谢谢

推荐答案

嗨Alan,

 问题在于双打。静态检查器具有有限的推理能力和双打(它基本上跟踪简单的间隔),在你的例子中这还不够。

  the problem is with doubles. The static checker has a limited reasoning capability with doubles (it essentially tracks simple intervals), and in your example this is not enough.

我们正在努力增加对浮点表达式的支持。

We are working to increase the support of floating point expressions.

谢谢

f


这篇关于与简单的算术失败的合同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆