This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Primitive Data Type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Primitive Data Type " Watch "Primitive Data Type " New topic
Author

Primitive Data Type

sr shashidhar
Greenhorn

Joined: Jan 17, 2013
Posts: 27
In the below program,

Only while using


Java Compiler gives Exception as

Exception in thread "main" java.lang.ArithmeticException: / by zero

Why not for Floating or Double type...?





Output:


Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43905
    
  32
I think you have already answered your own question. Because the IEEE745 floating‑point datatypes support ±∞ (and NaN), and the unsigned and two’s complement integer types do not support ∞.
sr shashidhar
Greenhorn

Joined: Jan 17, 2013
Posts: 27

Thanks Campbell Ritchie.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43905
    
  32
You’re welcome
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Primitive Data Type
 
jQuery in Action, 3rd edition