<bdo id="vljxk"><rt id="vljxk"><noframes id="vljxk"><noframes id="vljxk"><noframes id="vljxk"><rt id="vljxk"></rt><rt id="vljxk"></rt><noframes id="vljxk"><rt id="vljxk"><delect id="vljxk"></delect></rt><noframes id="vljxk"><rt id="vljxk"></rt><noframes id="vljxk"><noframes id="vljxk"><rt id="vljxk"></rt>

當前位置:首頁 >  站長 >  編程技術 >  正文

Java中絕對值函數使用說明

 2021-01-20 16:47  來源: 網絡綜合   我來投稿 撤稿糾錯

  阿里云優惠券 先領券再下單

絕對值函數使用說明

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

申請創業報道,分享創業好點子。點擊此處,共同探討創業新機遇!

相關標簽
絕對值函數

相關文章

熱門排行

信息推薦