聚站网(手机站)有215个分类 51900个网站 2091篇文章
聚站网|网址导航|网站导航手机站LOGO
当前位置:聚站网 » 站长资讯 » 互联网资讯 » 优化推广 » 文章详细
Java中绝对值函数使用说明
 
发布时间:2021-10-03 浏览:84次

绝对值函数使用说明

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

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

 /**
 * Returns the absolute value of an {@code 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
 * {@link Integer#MIN_VALUE}, the most negative representable
 * {@code 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;
 }

  • ┃ 来源: 网络转载
  • ┃ 标签: 绝对值函数
  • 上一篇: 2021年SEO网站优化我们应该怎么做
  • 下一篇: AmazeUI 单选框和多选框的实现示例
  • ┃ 推荐资讯
    ┃ 今日新闻投稿
    ┃ 最新收录网站

     返回顶部