?? testmod.java
字號:
/**
* Description:
* <br/>Copyright (C), 2005-2008, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
public class TestMod
{
public static void main(String[] args)
{
double a = 5.2;
double b = 3.1;
double mod = a % b;
//mod的值為2.1
System.out.println(mod);
//輸出非數(shù):NaN
System.out.println("5對0.0求余的結果是:" + 5 % 0.0);
//輸出非數(shù):NaN
System.out.println("-5.0對0求余的結果是:" + -5.0 % 0);
//輸出0
System.out.println("0對5.0求余的結果是:" + 0 % 5.0);
//輸出非數(shù):NaN
System.out.println("0對0.0求余的結果是:" + 0 % 0.0);
//下面代碼將出現(xiàn)異常 java.lang.ArithmeticException: / by zero
System.out.println("-5對0求余的結果是:" + -5 % 0);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -