testfloatdouble.java
来自「基于LWVCL开发的库」· Java 代码 · 共 38 行
JAVA
38 行
class TestFloatDouble { static boolean failed = false; static void test(String s, String r) { if (!s.equals(r)) { System.out.println("result "+s+" should be "+r); failed = true; } } static void test(float v, String r) { test(Float.toString(v), r); } static void test(double v, String r) { test(Double.toString(v), r); } public static void main(String args[]) { System.out.println("Some mathmatical tests"); float f1 = 500.005f; float f2 = 400.004f; test(f1 * f2, "200004.0"); double d1 = 500.005; double d2 = 400.004; test(d1 * d2, "200004.00002"); String s = "Good"; if (failed) s = "Bad"; System.out.println("Results "+s); }}/* Expected Output:Some mathmatical testsResults Good*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?