Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

-10.0/0 and -10/0

 
david chan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why ?
double d = -10.0/0; //ok
double d = -10/0; //throw java.lang.ArithmeticException: / by zero
David
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic