当前位置:首页 » 《随便一记》 » 正文

Java中绝对值函数使用说明

23 人参与  2021年01月20日 00:00  分类 : 《随便一记》  评论

点击全文阅读


 

绝对值函数使用说明

绝对值函数是JDK中Math.java中的实现方法,其用来得到表达式的绝对值。

其实现非常简单,源码如下:

 /**
 * Returns the absolute value of an int} value.
 * If the argument is not negative, the argument is returned.
 * If the argument is negative, the negation of the argument is returned.
 *
 * <p>Note that if the argument is equal to the value of
 * Integer#MIN_VALUE}, the most negative representable
 * int} value, the result is that same value, which is
 * negative.
 *
 * @param a the argument whose absolute value is to be determined
 * @return the absolute value of the argument.
 */
 public static int abs(int a) {
 return (a < 0) ? -a : a;
 }

申请创业报道,分享创业好点子。,共同探讨创业新机遇!


点击全文阅读


本文链接:http://zhangshiyu.com/post/15369.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1