Hi,大家好,我是编程小6,很荣幸遇见你,我把这些年在开发过程中遇到的问题或想法写出来,今天说一说
java strictfp关键字_java.applet,希望能够帮助你!!!。
package com.keyword; import junit.framework.TestCase; public class TestStrictfp extends TestCase { public strictfp void testStrictfp() { float aFloat = 0.123f; double aDouble = 0.; double sum = aFloat + aDouble; float quotient = (float) (aFloat / aDouble); System.out.println("float: " + aFloat); System.out.println("double: " + aDouble); System.out.println("sum: " + sum); System.out.println("quotient: " + quotient); } public void testNoStrictfp() { float aFloat = 0.123f; double aDouble = 0.; double sum = aFloat + aDouble; float quotient = (float) (aFloat / aDouble); System.out.println("float: " + aFloat); System.out.println("double: " + aDouble); System.out.println("sum: " + sum); System.out.println("quotient: " + quotient); } }
我在32位的windows xp sp3上测试,结果是一样的,都是:
float: 0.123 double: 0. sum: 0. quotient: 0.
今天的分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。