java.lang.Math中 min(double a,double b) 提问public static double或者float min(double a,double b){// this check for NaN,from JLS 15.21.1,saves a method callif (a = a)return a;// no need to check if b is NaN; < will work correctly// recall that -0

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/28 16:08:40
java.lang.Math中 min(double a,double b) 提问public static double或者float min(double a,double b){// this check for NaN,from JLS 15.21.1,saves a method callif (a = a)return a;// no need to check if b is NaN; < will work correctly// recall that -0

java.lang.Math中 min(double a,double b) 提问public static double或者float min(double a,double b){// this check for NaN,from JLS 15.21.1,saves a method callif (a = a)return a;// no need to check if b is NaN; < will work correctly// recall that -0
java.lang.Math中 min(double a,double b) 提问
public static double或者float min(double a,double b)
{
// this check for NaN,from JLS 15.21.1,saves a method call
if (a = a)
return a;
// no need to check if b is NaN; < will work correctly
// recall that -0.0 == 0.0,but [+-]0.0 - [+-]0.0 behaves special
if (a == 0 && b == 0)
return -(-a - b);
return (a < b) a :b;
}
1.为什么 if (a = a)后返回a呢?
2.if (a == 0 && b == 0)
return -(-a - b);

java.lang.Math中 min(double a,double b) 提问public static double或者float min(double a,double b){// this check for NaN,from JLS 15.21.1,saves a method callif (a = a)return a;// no need to check if b is NaN; < will work correctly// recall that -0
NaN = not a number(非法浮点)
NaN =!NaN (它的性质)
你搜“Java NaN”会告诉你非法浮点(NaN)的性质,NAN是无序的,
比较时,总是返回false,
所以,当a为非法浮点时,a!=a 就为真,就返回a作为最小值.
----------------------------------------------------------------------------------
if (a==0 && b==0) 当a或b 接近0.0时,
有点费解,你先搜一搜,文章很多.
学语言一定要学会搜索,否则,你的疑问会太多

java.lang.Math中 min(double a,double b) 提问public static double或者float min(double a,double b){// this check for NaN,from JLS 15.21.1,saves a method callif (a = a)return a;// no need to check if b is NaN; < will work correctly// recall that -0 java.lang.ArithmeticException: / by zeroat java.math.BigDecimal.divi谁知道这个错误?java.lang.ArithmeticException: / by zero at java.math.BigDecimal.divide(BigDecimal.java:1327) at com.picc.scms.inf.service.spring.MyCommissionDeta java.lang.illegalstateexception java.lang.IllegalStateException是什么? java.lang.InstantiationException是什么意思 java.lang.IllegalArgumentException是什么意思 Java.lang.outofmemovyerror是什么意思 java.lang.NoSuchMethodError:getViewUnit java.lang.NoSuchMethodException是什么意思 java编程 求解一元二次方程:ax^2+bx+c=0编写一个程序,求解一元二次方程:ax^2+bx+c=0 .参数a,b及c从命令行输入.提示:需要用到 java.lang.Math 类,Math 类中提供了多种用于科学计算的方法,例如开方 sq k=java.lang.Math.sqrt(m) 是不是调用java里面本来就有的函数?rt 还有什么相关的函数需要记住或常用的呢? java.lang.IllegalArgumentException何解? java.lang.IllegalArgumentException怎么解 java.lang.Exception, java.lang.RuntimeException, java.lang.Error的区别 JAVA题,使用java.lang.Math类,生成50个0到99之间的不重复的随机整数,并按降序的顺序输出这些整数使用java.lang.Math类,生成50个0到99之间的不重复的随机整数,并按降序的顺序输出这些整数.提示:Math JAVA中,% == && || Math.sqrt(x) Math.pow Math.floor(x) Math.round(x)各是什么意思?非常急 使用java.lang.Math类,生成100个0~99之间的随机整数,找出它们之中的最大者和最小 java.lang.integer.MAX_VALUE 啥意思?