This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes -10.0/0 and -10/0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "-10.0/0 and -10/0" Watch "-10.0/0 and -10/0" New topic
Author

-10.0/0 and -10/0

david chan
Ranch Hand

Joined: Jun 10, 2002
Posts: 46
why ?
double d = -10.0/0; //ok
double d = -10/0; //throw java.lang.ArithmeticException: / by zero
David
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Java uses the IEEE specification for float arithmetic which says that divide by zero returns infinity. Integer divide by zero throws an exception.
http://www.javaworld.com/javaworld/jw-10-1996/jw-10-hood.html


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
davidchantf,
Welcome to Javaranch
We'd like you to read the Javaranch Naming Policy and change your publicly displayed name to comply with our unique rule. Thank you.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
Don't get me started about those stupid light bulbs.
 
subject: -10.0/0 and -10/0
 
Similar Threads
How to best convert for example 2.29 -> 2.3
Division by ZERO
Wrapper class
q from Sahir's mock
Arithmetic Exception