Overflow and Underflow : Arithmatic Operators « Operators « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Operators » Arithmatic Operators 
2.5.16.Overflow and Underflow
public class MainClass{
 public static void main(String args[]) {
  int n = 2000000000;
  System.out.println(n * n);
 }
}
-1651507200
2.5.Arithmatic Operators
2.5.1.Arithmetic Operator Summary
2.5.2.The * and / operators perform multiplication and division on all primitive numeric types and char.
2.5.3.Integer division will generate an ArithmeticException when attempting to divide by zero.
2.5.4.Multiply can cause overflow.
2.5.5.Divide can cause underflow.
2.5.6.Integer Division and Division by Zero
2.5.7.Division of an integer by zero results in the throwing of an ArithmeticException.
2.5.8.A positive floating-point value / zero results = POSITIVE_INFINITY.
2.5.9.A negative floating point value / zero = NEGATIVE_INFINITY.
2.5.10.Modulo Operations: x % y = x - ((int) (x/y)*y).
2.5.11.Java allows floating-point operands to be used with the % operator.
2.5.12.The Modulo Operator % gives the remainder of a division.
2.5.13.Apply Modulo Operator % to floating-point numbers
2.5.14.Apply Modulo Operator % to negative numbers
2.5.15.Apply Modulo Operator %, what if the second operand is 0
2.5.16.Overflow and Underflow
2.5.17.+ operator is overloaded by the Java language for String
2.5.18.Number types get converted when plusing to a string
2.5.19.Conversion to a String object is performed by invoking the toString() method of that object.
2.5.20.String concatenation gets interesting when you combine numbers with Strings
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.