国产在线精品观看_免费国产a国产片高清不卡_国产三级电影免费看_男人天堂网站在线

互聯網+內容
134-1887-2552

Java中絕對值函數使用說明

標簽:深圳網站建設公司2021-01-21 1024

絕對值函數使用說明

絕對值函數是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;
 }

微信分享領紅包!
相關閱讀 / 返回上一頁