此网站为SEO优化技术博客内容分享网站,有需要咨询网站优化,网站建设,外链代发,友情链接,快排优化等相关问题请联系我们!
当前位置:晴天博客 > SEO优化技巧 > 正文

Java中绝对值函数使用说明

 绝对值函数使用说明

绝对值函数是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;
 }

版权保护: 本文由 晴天博客 互联网采集发布,转载请保留链接: http://www.qtbok.com/html/3736.html