双重和平等 [英] On Doubles and Equality

查看:79
本文介绍了双重和平等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其中一种方法我已经返回一个 double 。在 jUnit 中测试此方法时,我注意到以下奇怪:

One of the methods i have returns a double. When testing this method as part of my jUnit, i noticed the following oddity:

    String a = "someString";
    String b = "someDifferentString";

    double result = c.getScore(a, b, true);
    System.out.println(result); // prints 0.0

    assert (result > 0.0); // Test passes

所以..我问你,如何可以0.0多0.0?为什么 result> 0.0 评估为 true

So .. I ask you, how can 0.0 be more then 0.0? Why does result > 0.0 evaluates to true?

推荐答案

assert是一个Java关键字。你需要 assertTrue(result> 0.0)

assert is a Java keyword. You need assertTrue(result > 0.0)

这篇关于双重和平等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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