⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sample1_3.java

📁 实现用于工程计算的的数学方法
💻 JAVA
字号:
/*
 * 示例程序Sample1_3: 溢出
 */
package javaalgorithm.sample;

public class Sample1_3 
{
	public static void main(String[] args) 
	{
		//
		// 整数溢出
		//
		int maxInt = 2147483647;
		int minInt = -2147483648;
		int a = maxInt + 1;
		int b = minInt - 1;
		int c = maxInt * 2;
		System.out.println("整数上溢:");
		System.out.println("maxInt = " + maxInt);
		System.out.println("maxInt + 1 = " + a);
		System.out.println("maxInt * 2 = " + c);
		System.out.println("整数下溢:");
		System.out.println("minInt = " + minInt);
		System.out.println("minInt - 1 = " + b);
		
		//
		// 浮点数溢出
		//
		float maxFloat = 3.4028235E38f;
		float u = maxFloat * 2;
		System.out.println("\n浮点数上溢:");
		System.out.println("maxFloat = " + maxFloat);
		System.out.println("maxFloat * 2 = " + u);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -