• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

exception doubt

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
int a = 12/0 throws java.lang.ArithmeticException: / by zero
but double i = 1.2/0; is not throwing any exception.
please explain reason for this
 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because using integral types devided by zero wil cause ArithmeticException
But when use floating point numbers(float or double)then will not give that exception ,for instance:



ForExample:
double d=1.0/0;
System.out.println(d==Double.POSITIVE_INFINITY);

double d2 = -1.0/0;
System.out.println(d2==Double.NEGATIVE_INFINITY);

I Think that is answered to your question..you can mail me:
alaa56mm@gmail.com
[ May 01, 2006: Message edited by: alaa hassan ]
 
vijay Thiru
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dear alaa hassan ,
thanks a lot
 
reply
    Bookmark Topic Watch Topic
  • New Topic